PHP Developers Network
http://forums.devnetwork.net/

help with Match all except specific pattern
http://forums.devnetwork.net/viewtopic.php?f=38&t=141735
Page 1 of 1

Author:  zintonio [ Wed Sep 09, 2015 3:54 am ]
Post subject:  help with Match all except specific pattern

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

Author:  Christopher [ Wed Sep 09, 2015 9:59 am ]
Post subject:  Re: help with Match all except specific pattern

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

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/