murugu has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks
I am currently processing the text in a file. I want to change the hyphenated words in the file in to some other format as mentioned below
input
my father-in-law is a chemist who is currently working with αphenol-acetate.
output
my father<->in<->law is a chemist who is currently working with αphenol<->acetate.
In the above input the hyphens should be replaced with <->. we are having another file file2 which consist of the hyphenated words list. we have to replace the text in file1 which matches the text present in file2.
The problem is when we wrote an regular expression to match the hyphenated words, except the words starting with ampersand all other words are matched.
the regular expression is
m/\b[;&\w]+([-\w;&]+)+\b/gsi;
Why our code is not matching the words starts with ampersand. Is there any other way to solve this. If so we need regular expression
---Murugesan and Prasad---
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(z) Re: Regex not matching &
by zigdon (Deacon) on Mar 18, 2004 at 15:42 UTC | |
|
Re: Regex not matching &
by Abigail-II (Bishop) on Mar 18, 2004 at 15:45 UTC | |
by murugu (Curate) on Mar 18, 2004 at 15:57 UTC | |
by Abigail-II (Bishop) on Mar 18, 2004 at 16:24 UTC | |
|
Re: Regex not matching &
by CombatSquirrel (Hermit) on Mar 18, 2004 at 16:24 UTC | |
|
Re: Regex not matching &
by Anomynous Monk (Scribe) on Mar 18, 2004 at 18:51 UTC | |
by murugu (Curate) on Mar 19, 2004 at 02:57 UTC | |
by Anonymous Monk on Jul 14, 2005 at 15:50 UTC |