- Nov 4, 2004
- 1,274
- 0
- 0
Hey
Well I'm writing a Bencoding class in Java for my own BitTorrent client from scratch (just for fun.. I know there are a billion of them
) I'm trying to decode strings and I lack the regex skills to do the check.
Basically a string is encoded into the message with the length prefix (base ten) a separating colon and the string (along with the rest of the bencoded message).
8:doorknobxyz
where I want to check that the prefixed length matches enough characters (8 characters in doorknob, the ending xyz represents the rest of the bencoded message which is ignore at this point). So far I've come up with:
^([0-9]+):.{}$
I don't know what expression to put inside the {} though. IIRC (it has been years) in PERL you could reference the groupings using $1, $2... $9 but that was a language feature itself. Is there anyway which I can take the grouping value (in this case its a base ten length value) and put it into the { } ?
thanks
Well I'm writing a Bencoding class in Java for my own BitTorrent client from scratch (just for fun.. I know there are a billion of them
Basically a string is encoded into the message with the length prefix (base ten) a separating colon and the string (along with the rest of the bencoded message).
8:doorknobxyz
where I want to check that the prefixed length matches enough characters (8 characters in doorknob, the ending xyz represents the rest of the bencoded message which is ignore at this point). So far I've come up with:
^([0-9]+):.{}$
I don't know what expression to put inside the {} though. IIRC (it has been years) in PERL you could reference the groupings using $1, $2... $9 but that was a language feature itself. Is there anyway which I can take the grouping value (in this case its a base ten length value) and put it into the { } ?
thanks
