regexp question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a text and I want to match several words like this "(controller|
data|IT)?" at least one of the words in the group should be mandatory,
but I dont want to match a word that is part of another word like this
"datamanager" it should only match the word "data" or any other word
in the group.

Any suggestions?

Re: regexp question

Kris wrote:
Quoted text here. Click to load it

You know there are classes for characters, like \w? Well there are
classes for non characters:
^   Start of Line or Data
$   End of Line or Data
\b  Word-boundery, change from \w to \W

->   "(\b(controller|data|IT)\b)?"

But some letters like German umlaute may be seen as Non-Word-Elements,
depending on your the encoding.

In this cases you may try search for your words between non letters.
->   "((\s|^)(controller|data|IT)(\s|$))?"

what about data-base?

-- Namensportal zu Richler Heiko Richler: Computer - Know How! private Homepage

Re: regexp question

Quoted text here. Click to load it

Hi Heiko

thanks for the reply

I know about boundaries and such, just couldnt get it to work, now I
see why, I had tesed \b(controller...)\b which didnt work as intended.


Site Timeline