Link to home
Start Free TrialLog in
Avatar of Hepen
Hepen

asked on

Get data between a string?

How do I get data between a string?

"************<hello world>***************************"

how do i return hello world without the < and > ?

the easiest .net efficient way

the **** is symbolizing a random length.
ASKER CERTIFIED SOLUTION
Avatar of Naveen Swamy
Naveen Swamy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ZeonFlash
ZeonFlash

Always the sucker for a RegEx, you can try this too:

Dim regx As New System.Text.RegularExpressions.Regex("^.*[<]{1}(?<TheString>([\w\s]{0,}))[>]{1}.*$")
Dim str As String = "************<hello to 24 the world>***************************"

With regx.Match(str)
     MsgBox(regx.Replace(str, .Groups("TheString").Value))
End With
Avatar of Bob Learned
Easier Regex pattern:

  Dim pattern As String = "[\w\s]+"

  Dim match As New Regex(input, pattern)
  If match.Success Then
      MessageBox.Show(match.Value)
  End If

Bob
Hello, Hepen,

If you are sure that you have a "<" and at least one character prior to it, you could use:

        strTest.Split("<"c, ">"c)(1)

where strTest contains your string.

Cheers,
Randy