<?xml version="1.0" encoding="windows-1252"?>
<node id="1017302" title="Re: Using special characters in left part of a regex match?" created="2013-02-05 18:28:40" updated="2013-02-05 18:28:40">
<type id="11">
note</type>
<author id="396320">
punch_card_don</author>
<data>
<field name="doctext">
To my mind, you have a logic issue long before you have a regex syntax issue.
&lt;p&gt;
Does the first phrase ($var[0]) always define the full version of the phrase?  If so, ok, straight forward enough.  But if not, then how do you decide which phrases define what is "normal" to be in the phrase, and which have a variant?  The human brain may be able to see that naturally enough, but your code has no element of that.
&lt;p&gt;
&lt;b&gt;If&lt;/b&gt; the first phrase always defines the complete phrase, then, easy:
&lt;code&gt;

#!/usr/bin/perl -w
use strict;
use warnings;
print "Content-type:text/html\n\n";

my @var;
$var[0] = "Gallia est omnis divisa in partes tres";
$var[1] = "Gallia est omnis divisa in ...";
$var[2] = "Gallia est omnis ...";
$var[3] = "Gallia";
$var[4] = "... omnis divisa in ...";
$var[5] = "Gallia est ... tres";
$var[6] = "Gallia ... partes tres";
$var[7] = "Gallia est ... partes tres";
$var[8] = "Gallia ... divisa ... tres";
$var[9] = "... tres";
$var[10] = "quattuor";

my @base_phrase_words = split(/\s/, $var[0]);
push(@base_phrase_words, "...");
my %words = map { $_ =&gt; 1 } @base_phrase_words;

for (my $i=1; $i&lt;=$#var; $i++) {
	my @partial_phrase_words = split(/\s/, $var[$i]);
	foreach my $element (@partial_phrase_words){
		if (exists($words{$element})) {
			# do whatever
		}
		else {
			print "&lt;p&gt;Found word $element in phrase $i varies from base phrase\n";
		}
	}
}

&lt;/code&gt;
Output
&lt;code&gt;
Found word quattuor in phrase 10 varies from base phrase 
&lt;/code&gt;




&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-396320"&gt;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;i&gt;&lt;font face="verdana" size=1&gt;Time flies like an arrow.  Fruit flies like a banana.&lt;/i&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1017293</field>
<field name="parent_node">
1017293</field>
</data>
</node>
