Reapz Posted December 31, 2003 Posted December 31, 2003 I have the following string... "some<text><999><STEAM_0:0:000000><text>again some other stuff" Howcome this... system.text.regularexpressions.regex("<.+><STEAM_.+:.+:.+><.+>") ...matches this... <text><999><STEAM_0:0:000000><text> ...when surely it should only match this... <999><STEAM_0:0:000000><text> ...? What am I missing? I need to match only <999><STEAM_0:0:000000><text> which works when there are no pointy brackets to the left of it but on some occasions such as above there may be and I have no control over how many or where they are placed. Cheers! Quote I'm getting the hang of this now... No really I am!
*Gurus* Derek Stone Posted December 31, 2003 *Gurus* Posted December 31, 2003 "<text><999>" matches the regular expression "<.+>". It starts with a less-than character, has text in the "middle", and ends with a greater-than character. If you want to limit it to just as single tag use "[^<>]". Quote Posting Guidelines
Reapz Posted January 1, 2004 Author Posted January 1, 2004 Yea... Of course that's logical. I tried substituting the first <.+> with [^<>] like you said but it just returned the whole line. Maybe I've got the wrong end of the stick. What I've got is this... (Currentline = the string from above.) Dim reUID As New System.Text.RegularExpressions.Regex("(<.+><STEAM_.+:.+:.+><.*>)") Dim Parts = reUID.Split(CurrentLine) What I'm trying to get is... Parts(0) = "some<text>" Parts(1) = "<999><STEAM_0:0:000000><text>" Parts(2) = "again some other stuff" Like I said this works fine if the only <'s and >'s are the ones in <999><STEAM_0:0:000000><text> which is 99% of the time but not if there are any preceeding that part. What corrections do I need to make in my regex? Quote I'm getting the hang of this now... No really I am!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.