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

regex 1

Status
Not open for further replies.

w5000

Technical User
Nov 24, 2010
223
PL

hello,
could someone please tell why the red regex does not work - I need to be sure line contains on first filed
if and then [numbers][whitespace]=[whitespace] and the rest not important here

Code:
$ echo "if1     sfdsf\nif12 = jfsflk\n   if4    =       sfsf"|awk '$1~/^if[0-9]+/'
if1     sfdsf
if12 = jfsflk
   if4    =       sfsf
$ echo "if1     sfdsf\nif12 = jfsflk\n   if4    =       sfsf"|awk '$1~/^if[0-9]+[COLOR=#EF2929][[:space:]]*=[[:space:]]*[/color]/'
$ echo "if1     sfdsf\nif12 = jfsflk\n   if4    =       sfsf"|awk '$1~/^if[0-9]+[COLOR=#EF2929][ \t]+=[ \t]+[/color]/'
$
 
Get rid of $1~

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
indeed...thank you!
anyhow I changed it to:
awk '$1~/^if[0-9]+/&&$2=="="'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top