marklarah Posted April 3, 2012 Share Posted April 3, 2012 Hey hey dudes So I'm fairly new to regex (I've avoided having to write my own expressions up till now lol) So I have a big expression that matches URLs, but I don't want it to match if it's proceeded by something. To boil it down and put it simply, something like this ([a-z]+)(?!( hi)) with string "hello hi" would match "hell", but how would I make it so it matches nothing? ie how do I put everything else that I'd normally test for together in a group or something, with a conditional that if everything is proceeded by something else, the whole thing returns no matches. Hope I'm making myself clear.... Thanks! Mark Quote Link to comment Share on other sites More sharing options...
abareplace Posted April 4, 2012 Share Posted April 4, 2012 Hi, Mark, you should check that the word ends here: ([a-z]+)\b(?!( hi)) \b is a word boundary (in this case, the end of the word). Quote Link to comment Share on other sites More sharing options...
marklarah Posted April 4, 2012 Author Share Posted April 4, 2012 You sir, are a god amongst men. Many thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.