water has asked for the wisdom of the Perl Monks concerning the following question:
I'm having trouble writing a regexp to tag text with markup that preserves case. For example, say I want to replace
with/\b[Ca]at\b/
or<span class="topic">Cat</a>
depending on the original case of 'cat'.<span class="topic">cat</a>
The /i flag helps with the match, but unsure how to get the right case on the first letter.
I'm matching many patterns against many peices of text.
thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: case preservation in regexp
by cog (Parson) on Feb 10, 2005 at 11:56 UTC | |
|
Re: case preservation in regexp
by BrowserUk (Patriarch) on Feb 10, 2005 at 11:58 UTC | |
|
Re: case preservation in regexp
by CountZero (Bishop) on Feb 10, 2005 at 12:38 UTC | |
by halley (Prior) on Feb 10, 2005 at 18:04 UTC | |
|
Re: case preservation in regexp
by revdiablo (Prior) on Feb 10, 2005 at 17:45 UTC | |
|
Re: case preservation in regexp
by perlsen (Chaplain) on Feb 10, 2005 at 12:45 UTC |