Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!

I'm getting the hang of this now... No really I am!
Posted

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?

I'm getting the hang of this now... No really I am!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...