I'm fairly new to regular expressions but I'm trying to create one which will
make keywords in a string bold on a web page. To identify the keywords in the
string I'm using the following Regular Expression, which mostly works, unless
there is a <br> directly before or after the keyword. If there is a <br>
directly before or after, the word before or after the <br> is also shown
bold.

"(\s{0,1}\S*(" + keywordArray(jLoop) + ")\S*\s{0,1})"
description = regEx.Replace(description, "<b>$1</b>")

I'm trying to match any words which contain the keyword, not just equal the
keyword.

Can anyone help? Thanks,

Carolyn

RE: RegEx help by CarolynSpeakman

CarolynSpeakman
Fri Nov 05 06:30:03 CST 2004

Nevermind, done it with the expression below.

"([ ]{0,1}[^> ]*(" + keywordArray(jLoop) + ")[^< ]*[ ]{0,1})"

Thanks anyway,
Carolyn

"Carolyn Speakman" wrote:

> I'm fairly new to regular expressions but I'm trying to create one which will
> make keywords in a string bold on a web page. To identify the keywords in the
> string I'm using the following Regular Expression, which mostly works, unless
> there is a <br> directly before or after the keyword. If there is a <br>
> directly before or after, the word before or after the <br> is also shown
> bold.
>
> "(\s{0,1}\S*(" + keywordArray(jLoop) + ")\S*\s{0,1})"
> description = regEx.Replace(description, "<b>$1</b>")
>
> I'm trying to match any words which contain the keyword, not just equal the
> keyword.
>
> Can anyone help? Thanks,
>
> Carolyn
>
>

RE: RegEx help by CarolynSpeakman

CarolynSpeakman
Fri Nov 05 07:49:02 CST 2004

For anyone who is interested, the final Pattern I've found is:

"([\w]*(" + keywordArray(jLoop) + ")[\w]*)"