Reputation: 1271
I'm don't know regex really well, so can someone give me example how to fix this regex http://rubular.com/r/UdzYMJc9iE:
/\b([stack over flow]+)+\b/
not to match whitespaces and to match only exact words (stack matches ac as word, I want to match only stack), tia.
I want when we have 'lorem etiam nam' to match only these exact 3 words from the regex, without spaces.
I tried using \s, \S, /x, but there was no result..
Upvotes: 1
Views: 1076
Reputation: 1980
I use this website if I need some help with RegEx: http://www.txt2re.com/
It is really useful as I don't need RegEx that often. And it is perfect for the occasional use.
To check the expression, and to refine it I then use http://www.gskinner.com/RegExr/ also a very good tool.
And I think you would want something like:
(word|second|third)+
Upvotes: 1
Reputation: 406
If you want to match all words, not any in particular, \b(\w+)+\b
should work.
Upvotes: 1
Reputation: 145512
If you only want to match three alternatives, use the |
syntax, and group them into normal parenthesis:
/\b(stack|over|flow)+\b/
Not sure about the +
or what exactly you wanted to match.
Upvotes: 2