tmajor99
asked on
Regular Expression to detect "/" within "( )".
I need a regular expression that can search for a "/" within "( )".
Data
Wall-Mount (InWall / Plate) = True
Wall/Mount (test) = Not True
Wall-Mount (test) = Not True
(1/2) Test = True
(Test, Test/TEST) 123 = True
/Test = Not True
/Test/ = Not True
(/Test Abc = Not True - No closing ")"
Data
Wall-Mount (InWall / Plate) = True
Wall/Mount (test) = Not True
Wall-Mount (test) = Not True
(1/2) Test = True
(Test, Test/TEST) 123 = True
/Test = Not True
/Test/ = Not True
(/Test Abc = Not True - No closing ")"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I am not an expert of regular expression but why can we not use simply this?
\(.*\/.*\)
Subodh, the primary reason is because it would match things like (...) / (...) where there are parens on both sides but the slash is not within them.
Yes, that makes sense.
I proposed that pattern based on the sample data only. :)
I proposed that pattern based on the sample data only. :)
Open in new window
The middle group will only match if the prefix and suffix are both present.