user707549
user707549

Reputation:

the regular expressions in tcl

I have a question about regular expressions in tcl what does the following code means:

set servRef "servRef=(\\d+)"

set the variable servRef as "servRef=(\d+)"; what does this mean?

the code following above one is to pass the servRef as a patarmer to a function, take the servRef value and send the message to it. so what does the "servRef=(\d+)" means )

Upvotes: 1

Views: 284

Answers (2)

RHSeeger
RHSeeger

Reputation: 16262

You've overthinking the problem a little. What you have

set servRef "servRef=(\\d+)"

is just a command that sets the variable servRef to the value servRef=(\d+) . That value may be used by another command as a regular expression later, but it's just a value here.

Its useful to remember that Tcl doesn't have many context sensitive constructs.

Upvotes: 3

Colin Macleod
Colin Macleod

Reputation: 4372

You don't show enough of the context to be sure, but I would guess that later on $serfRef will be used as the pattern to match in a regexp command which scans some input for a string like serfRef=1234 and extracts the 1234 into a sub-match variable for later use. For more info see the Tcl wiki regexp page.

Upvotes: 2

Related Questions