Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

tcl query for regular expression

Status
Not open for further replies.

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.
 

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.

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

    Points: 2
    Helpful Answer Positive Rating
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!!
 

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!!

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
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top