Kezziny
Kezziny

Reputation: 13

c# regexp pattern to <id> .... </id>

I wrote the following pattern:

@"<([0-9]+)>(.*?) < /$1>"

but it doesn't work. how could i refer to the first group?

source text:

"Method()<0>int x = 0; while(x < 10)<1>echo(x)< /1>< /0>"

Upvotes: 1

Views: 98

Answers (1)

Kobi
Kobi

Reputation: 137997

That would be \1, and watch for spaces.
See also: .Net Regex Backreferencing

Upvotes: 2

Related Questions