help with Match all except specific pattern

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
zintonio
Forum Newbie
Posts: 1
Joined: Wed Sep 09, 2015 3:43 am

help with Match all except specific pattern

Post by zintonio »

Hi all, i have some problem matching everything except a specific pattern. I post an example:

My string is:
test 1) test2 3) test3 22) test5 34)

What i need to select is everithing except 1) 3) 22) 34)

I used this (?!\d+\)). but this pattern match only the numbers. I mean the result is : test ) test2 ) test3 ) test5 )
Instead I would like to have this: test test2 test3 test5

How can I do to do that?
Thanks in advance
User avatar
Christopher
Site Administrator
Posts: 13595
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: help with Match all except specific pattern

Post by Christopher »

You could try negative lookahead, something like: "/(?! [0-9]*\)))/"
(#10850)
Post Reply