in reply to Regular Expression
Please go through Regular Expressions tutorials for a better understanding, these are very simple search techniques This is my programif($line =~ m/^Width(\s*)\=(\s*)(\d*)/)#to match width
UPDATE:: So, WW I haven't said that this is the only way there are lots of way to do things in perl. Secondly, I didn't say that what you need to print the width value. Yes $3 will give the exact output, while you are completely wrong on the statement that it will not match ) after equal to. Check it and then say.$line = 'Width = 32 <uart0_rx_data : 16\'h0000> Descr - "This is Regis +ter1 comment" f_name bit_pos RESERVED 31:8 RXDATA 5:0 + </uart0_rx_data>'; if($line =~ m/^Width(\s*)\=(\s*)(\d*)/) # to match Width { print "something"; } elsif ($line =~ m/^Descr[\s]*-[\s]*[\w]+$/) # to match Descr { print "noone"; } else { printf "Garbage found: \"%s\" \n",$line; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regular Expression
by ww (Archbishop) on Jun 27, 2012 at 14:15 UTC |