Reputation: 3060
Im trying a regex to exactly match against a given set of keywords in between delimiters?
For example:
Keywords: keyone, keytwo, keythree Start delimiter: ; End delimiter: ;
Text under test: some text ;keyone; other text ;keytwo; some text ;keythreeeee;
Regex i tried : ;([keyonekeytwokeythree]+);
Problem with this regex is, this matching with keythreeeee also. My expectation is it should not match keythreeeee because this is not exact match.
Upvotes: 0
Views: 99
Reputation: 11
I first take all the text inside delimiters.
(delmiterSart)(.)*(delimiterEnd)
and then on this selected text i try to search you word
(key1|key2|keyn)+
Upvotes: 0
Reputation: 41958
You should read up on regular expression syntax.
([keyonekeytwokeythree]+)
The square bracket syntax tells the regexp matcher to match 'any number of characters from the set keyonekeytwokeythree
'. It will thus also match yekenoeerth
.
You're looking for something like:
;(keyone|keytwo|keythree);
Upvotes: 2