in reply to Re: Regex not matching &
in thread Regex not matching &

Actually what we are doing is we have two files. File 1 is an XML file. File 2 is a text file which consist of words with hyphenations.

FILE-I

<element id="10">&alpha;phenol-acetate and Ace-tone and 5-ethyl-alcohol</element>

File-II

Ace-tone

&alpha;phenol-acetate

I want to replace the hyphenated words present in file1 which is also present in file2 with hyphens changed into <->.

is the problem is now clear

we want the regular expression

thanks for ur kind reply

Replies are listed 'Best First'.
Re: Regex not matching &
by Abigail-II (Bishop) on Mar 18, 2004 at 16:24 UTC
    Eh, no. The problem is not clear. Any problem that considers matching "words" isn't clear unless there is a clear (sic) definition of what a word is. Your original code allows "words" to contain semi-colons, dashes and ampersands. Are you considering ;-; to be a word? Is father-in-law&mother-in-law one or two words? Etc, etc.

    Once you have a clear definition of what you are going to consider words, writing a regex is likely to be easy.

    Abigail