I am trying to divide a string similar to this:
"<span>1</span> - Selection"
And get the value that is enclosed between the <span>
.
In JavaScript
I do this:
var example= "<span>1</span> - selection";
var separation= example.replace("</span>","<span>").split("<span>");
console.log("Split: ",separation);
//The result is ["","1"," - Selección"]
console.log("Value that I want: ",separation[1]); //I get the value that I need
And that's it that I need to do but in Visual .NET, but it doesn't work for me.
I try:
Dim WordString As String = "<span>1</span> - Selection"
Dim idSelection As String() = WordString.Replace("</span>","<span>").Split("<span>")
or sending all the </span>
replaced in the string to just do:
Dim WordString As String = "<span>1<span> - Selection"
Dim idSelection As String() = WordString.Split("<span>")
But in the position (1) I always get "span>1"
, and I can't do the split like in JS
How can I do it correctly?
To simulate the code VB.Net
use https://dotnetfiddle.net/
The code:
Imports System
Public Module Module1
Public Sub Main()
Dim WordString As String = "<span>1</span> - Selection"
Dim idSelection As String() = WordString.Replace("</span>","<span>").Split("<span>")
Console.WriteLine(idSelection(1))
End Sub
End Module