Mar 14, 2007 #1 I incisive Member level 4 Joined Jul 22, 2005 Messages 77 Helped 4 Reputation 8 Reaction score 0 Trophy points 1,286 Activity points 1,798 tcl regular expressions Hello all, suppose i need to search atom from a group of lines from a file, for example file is item list atom [3:0] grant; ready here i need to change the 3rd line from "atom [3:0] grant" to "atom [7:0] grant" what is the necessary regular expression to do the above. i will be helpful if some gives some sought of clue to solve the above thanks incisive.
tcl regular expressions Hello all, suppose i need to search atom from a group of lines from a file, for example file is item list atom [3:0] grant; ready here i need to change the 3rd line from "atom [3:0] grant" to "atom [7:0] grant" what is the necessary regular expression to do the above. i will be helpful if some gives some sought of clue to solve the above thanks incisive.
Mar 15, 2007 #2 M microe_victor Junior Member level 2 Joined Nov 18, 2006 Messages 22 Helped 7 Reputation 14 Reaction score 5 Trophy points 1,283 Activity points 1,443 incisive said: Hello all, suppose i need to search atom from a group of lines from a file, for example file is item list atom [3:0] grant; ready here i need to change the 3rd line from "atom [3:0] grant" to "atom [7:0] grant" what is the necessary regular expression to do the above. i will be helpful if some gives some sought of clue to solve the above thanks incisive. Click to expand... hi , you can have a try with the regular expression below. % set a {atom [7:0]} atom [7:0] % regsub -all {(^atom[ \t]*\[)[0-9]+(\:0\])} $a {\17\2} c 1 % puts stdout $c atom [7:0] %
incisive said: Hello all, suppose i need to search atom from a group of lines from a file, for example file is item list atom [3:0] grant; ready here i need to change the 3rd line from "atom [3:0] grant" to "atom [7:0] grant" what is the necessary regular expression to do the above. i will be helpful if some gives some sought of clue to solve the above thanks incisive. Click to expand... hi , you can have a try with the regular expression below. % set a {atom [7:0]} atom [7:0] % regsub -all {(^atom[ \t]*\[)[0-9]+(\:0\])} $a {\17\2} c 1 % puts stdout $c atom [7:0] %
Mar 15, 2007 #3 I incisive Member level 4 Joined Jul 22, 2005 Messages 77 Helped 4 Reputation 8 Reaction score 0 Trophy points 1,286 Activity points 1,798 Thank you microe_victor, Even i found out a simple expression which changes the given value accordingly. i.e regsub {\[3:0\]} $sample3 {[7:0]} sample5 well thanks again!!
Thank you microe_victor, Even i found out a simple expression which changes the given value accordingly. i.e regsub {\[3:0\]} $sample3 {[7:0]} sample5 well thanks again!!
Mar 15, 2007 #4 M microe_victor Junior Member level 2 Joined Nov 18, 2006 Messages 22 Helped 7 Reputation 14 Reaction score 5 Trophy points 1,283 Activity points 1,443 incisive said: Thank you microe_victor, Even i found out a simple expression which changes the given value accordingly. i.e regsub {\[3:0\]} $sample3 {[7:0]} sample5 well thanks again!! Click to expand... You are welcome. in this case " regsub {\[3:0\]} $sample3 {[7:0]} sample5 " all the patten [3:0] would be replaced by [7:0] ,so please be careful
incisive said: Thank you microe_victor, Even i found out a simple expression which changes the given value accordingly. i.e regsub {\[3:0\]} $sample3 {[7:0]} sample5 well thanks again!! Click to expand... You are welcome. in this case " regsub {\[3:0\]} $sample3 {[7:0]} sample5 " all the patten [3:0] would be replaced by [7:0] ,so please be careful