Case-insensitive, lookaround, variable replacement!
Posted: Tue Feb 07, 2006 9:49 pm
I need to look take a long text string and replace certain smaller strings within it. Specific requirements:
1) The strings to match need to be passed as variables.
2) Matches should look ahead (and behind) to non-alphabetical characters. (The point being to prevent matches within a word -- e.g., I don't want "sting" to match "interesting.")
3) I need this to be case-INsensitive.
I've discovered ways of doing each of these things individually, but for some reason I can't get them to work together. For example, I can only manage to get case-insensitive results with eregi_replace, but I can only get the lookaround to work with preg_replace.
How can I do all these things at once?
1) The strings to match need to be passed as variables.
2) Matches should look ahead (and behind) to non-alphabetical characters. (The point being to prevent matches within a word -- e.g., I don't want "sting" to match "interesting.")
3) I need this to be case-INsensitive.
I've discovered ways of doing each of these things individually, but for some reason I can't get them to work together. For example, I can only manage to get case-insensitive results with eregi_replace, but I can only get the lookaround to work with preg_replace.
How can I do all these things at once?