tags:

views:

43

answers:

1

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>"
+2  A: 

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

Kobi
I don't think `0` is a legal tag name for XML, so an XML parser will probably complain.
strager
Even if regex works in this case, do read up on why true regex in general fails to parse XML files.
Hamish Grubijan
@strager - Good point, I didn't see these until I edited the question `:P`
Kobi
@strager it isn't a tag name it's a value in the node
msarchet
@Hamish Grubijan, I'm well aware of this. @msarchet, Pardon? I'm not sure what you're saying.
strager
right, i'm a fool.thanks very much
Kezziny