Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I match parentheses in regexp ?

Status
Not open for further replies.

fred78350

IS-IT--Management
Aug 9, 2000
1
FR
I am currently writing a NIS netgroup parser,<br>by isolating metaclasses from tokens (eg. (,login,-))<br><br>What is the correct regexp to match parentheses ?<br>I tried /[.(.].*[.).]/ but it has no effect.<br>I suppose I could have done it with the octal code of '(' and ')' but I dunno it.<br><br>Thanks for help !<br><br>Regards.
 
Here are some regexp for parens:<br><br>/\(/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# match open paren&nbsp;&nbsp;( escape paren with \ )<br><br>/\)/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# matches close paren<br><br>/[(¦)]/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# this will match open and close parens<br><br>Example:&nbsp;&nbsp;awk one-liner to print lines in file that<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;contain either kind of parens and print to<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stdout.<br><br>awk '/[(¦)]/ {print}' file<br><br>Hope this helps you.<br><br><br> <p>flogrr<br><a href=mailto:flogr@yahoo.com>flogr@yahoo.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top