|
-
Jul 14th, 2009, 05:32 PM
#1
Thread Starter
Lively Member
Regex match strings between , only when outside of complete brackets
Hello,
I am trying to make a regex that will match strings between a comma only if the comma is outside of complete brackets. Brackets inside of " " should not count. Examples below.
one(1,2),two(3,4)
should match:
one(1,2)
two(3,4)
test(ok(1,2),2),another(5,testing(3,4))
should match:
test(ok(1,2),2)
another(5,testing(3,4))
A more complex finale:
test(check(onemore(ok,4,9),"no"),"(","2","3"),next("forward",ok(34.2),"3,2,5"),last(1,2)
This should match:
test(check(onemore(ok,4,9),"no"),"(","2","3")
next("forward",ok(34.2),"3,2,5")
last(1,2)
Thanks in advance.
-
Jul 14th, 2009, 06:16 PM
#2
Re: Regex match strings between , only when outside of complete brackets
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 14th, 2009, 06:40 PM
#3
Addicted Member
Re: Regex match strings between , only when outside of complete brackets
After much guessing and checking, I ended up with this:
Code:
[a-z]+\(([a-z0-9,."\(]*,[a-z]*\(?[a-z0-9,."\)]*)?\)
It should work for what you need, but this was a pretty complex regexp, and I'm not a genius.
Although with one exception; in the last example, you'll get this:
test(check(onemore(ok,4,9),"no")
next("forward",ok(34.2),"3,2,5")
last(1,2)
This is because there is 4 begin parentheses and 3 close parentheses in this:
test(check(onemore(ok,4,9),"no"),"(","2","3")
I don't have time to try and figure something else out.
I really suggest you try to learn regexp for yourself via the links .paul. gave you. There are also many regexp testers on the internet so you can experiment, which is exactly what I do.
-
Jul 14th, 2009, 07:51 PM
#4
New Member
Re: Regex match strings between , only when outside of complete brackets
Empyreal, you wouldnt happen to be Ms Empyreal off RS would you?
-
Jul 14th, 2009, 07:57 PM
#5
Addicted Member
Re: Regex match strings between , only when outside of complete brackets
Sorry, no; I'm not even sure what "RS" is. What is it?
-
Jul 14th, 2009, 07:58 PM
#6
New Member
Re: Regex match strings between , only when outside of complete brackets
-
Jul 14th, 2009, 08:00 PM
#7
Addicted Member
Re: Regex match strings between , only when outside of complete brackets
Oh; anyway, for future notice, if you want to ask someone something that is not related to the thread, please pm them. I realized this AFTER I already sent my message, so I'm guilty too =P
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|