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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegEx meets curly brace } - not 1

Status
Not open for further replies.

ChrB

Technical User
Feb 15, 2005
7
CH
Hi folks

I have - with your help - some code which shortens lines in a file to a specified length MaxLen:
Code:
    k = length
    while ( k > MaxLen ) {
      for (m = MaxLen; m > 0; m--) if (substr( $0, m, 1) == " ") break
      if ( m == 0 ) m = MaxLen
      print substr($0, 1, m) > Output
      $0 = substr($0,m+1)
      k -= m
    }

Now I recognised that I can not apply this to lines which include a curly brace.
Following the awk man I try a RegEx [tt]/[^}]/ [/tt] or [tt]/[^\}]/[/tt] but nothing happens. How do I exclude lines with a "}" ?

TIA
Chris
 
Add this line of code at the beginning of your awk program:
/\}/{print;next}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Yep that did the trick!

Thanks PHV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top