Pratibha Tomar
Pratibha Tomar

Reputation: 15

Regular expression in tcl - String

I have a problem. I have 1 variable

set a "mau_gigabitethernet0/0/cpu0/2"

with the help of regexp I need to fetch the 0/0/CPU0

I'm getting an error, “invalid escape \ sequence” can anyone help me..???

Upvotes: 1

Views: 1648

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137567

I'd look for something like this:

regexp {(?i)\d+/\d+/cpu\d+} $a extracted
puts $extracted

Note that the regular expression is in braces, not double-quotes. That is important. (If it was in double quotes, it would have to be "(?i)\\d+/\\d+/cpu\\d+" which is awkward.) Also, I use (?i) to mark it as a case-insensitive regular expression.

Upvotes: 4

Related Questions