Prismatic Posted December 13, 2008 Share Posted December 13, 2008 How would one go about matching the following in a string? (xxxx/yyyy) basically find anything inside a pair of quotes ( ) with a / in the middle so in this example: dfasdf asfasd : dsfasd asdfasd -.-- fhfg (40.34342/5.023424) asdf 40.34342 and 5.023424 would be matched? Solved (\s\((.*?)/(.*?)\)\s) Quote Link to comment https://forums.phpfreaks.com/topic/136798-solved-will-trade-cookies-for-regex-help/ Share on other sites More sharing options...
DarkWater Posted December 13, 2008 Share Posted December 13, 2008 I'm surprised that that is working. I'd have suggested: !\(.+?/[^)]+\)!s Quote Link to comment https://forums.phpfreaks.com/topic/136798-solved-will-trade-cookies-for-regex-help/#findComment-714631 Share on other sites More sharing options...
nrg_alpha Posted December 14, 2008 Share Posted December 14, 2008 I'm surprised that that is working. I'd have suggested: !\(.+?/[^)]+\)!s Alternatively, it could be simplified as such: #\([^)]+\)#s Quote Link to comment https://forums.phpfreaks.com/topic/136798-solved-will-trade-cookies-for-regex-help/#findComment-715262 Share on other sites More sharing options...
DarkWater Posted December 15, 2008 Share Posted December 15, 2008 He needs a / in the middle. Quote Link to comment https://forums.phpfreaks.com/topic/136798-solved-will-trade-cookies-for-regex-help/#findComment-715491 Share on other sites More sharing options...
nrg_alpha Posted December 15, 2008 Share Posted December 15, 2008 He needs a / in the middle. Oops, my bad. Must have fallen asleep at the keyboard.. Quote Link to comment https://forums.phpfreaks.com/topic/136798-solved-will-trade-cookies-for-regex-help/#findComment-715517 Share on other sites More sharing options...
DarkWater Posted December 15, 2008 Share Posted December 15, 2008 Actually, let me rewrite it so you get the matches grouped how you wanted: !\((.+?)/([^)]+)\)!s Quote Link to comment https://forums.phpfreaks.com/topic/136798-solved-will-trade-cookies-for-regex-help/#findComment-715521 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.