NevSoFly
asked on
Can't get the character set of [^]] to match "]" in regex (([^[])(-?\w)/)|(/(-?\w)([^]])).
I'm trying to create a regex that only matches when:
for example:
1[ts/tty]/a..[a/bravo] ntf/dt; c/[antenna/board] ---> should match /a, /d and c/
So far I have (([^[])(-?\w)/) ---> this matches /d and c/ but not /a. I have tried (([^[])(-?\w)/)|(/(-?\w)([ ^]])) but can't get the character set of [^]] to match "]".
An alphanumeric character that is not preceded by "[" but is followed by "/"
and a "/" & an alphanumeric character when there isn't a "]" in front of it.for example:
1[ts/tty]/a..[a/bravo] ntf/dt; c/[antenna/board] ---> should match /a, /d and c/
So far I have (([^[])(-?\w)/) ---> this matches /d and c/ but not /a. I have tried (([^[])(-?\w)/)|(/(-?\w)([
ASKER
Thanks for responding. I mean immediately preceded and vb.net.
Also, why would "f/" not satisfy the criteria? In other words, why does "/d" match, but "f/" does not?
And I do not understand why "/a" matches. According to your criteria:
But there most assuredly is a ] in front of the "/a".
"/" & an alphanumeric character when there isn't a "]" in front of it.
But there most assuredly is a ] in front of the "/a".
ASKER
That was a typo. f/ should also match. I'm sorry I was writing the example on the fly and missed my mistake.
ASKER
I'm doing a terrible job at explaining what I want. Sorry. A / and alphanumeric character or an alphanumeric character and / should always match unless they are inside a set of [].
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I made an edit to the above just now. Forgot one small character!
ASKER
I am using regexr.com to test the patterns out but your suggestion didn't match anything.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your help and suggestion. I will start using regexhero from now on.
Open in new window
** edit
Does "preceded" mean "immediately preceded," or just "preceded"? Also, what programming language or text editor are you using?