user2902205
user2902205

Reputation: 69

TCL Regexp Explanation

What does the below regexp mean. I could see that some value has to get assigned to "z"

regexp ${a}(.+?)($x) $y NULL p1 p2 p3 z p5

but what are these p1, p2 etc..

Thanks in advance.

Upvotes: 0

Views: 197

Answers (1)

pdw
pdw

Reputation: 8866

First, read the documentation for the TCL regexp command.

Armed with that information, we can deconstruct the command:

  • regexp: the command.
  • ${a}(.+?)($x): the pattern. You'll need to figure out the value of the a and x variables to get the full regex.
  • $y: the string that needs to be matched
  • NULL: the full match will be stored in the variable NULL. It seems the program doesn't care about this value.
  • p1 p2 p3 z p5: The matches of the subgroups of the regex will be stored in these variables. Apparently the regex is expected to have five subgroups. z will receive the match of the fourth subgroup.

Upvotes: 2

Related Questions