0

I am currently working on a project that has hit a bit of a snag. I have the following string;

<td class="bld"><span id="ref_12590587_l">5,304.48</span>

I want to cut this string so that only the "5,304.48" is remaining. I would also then like to remove the comma.

Thanks

Edited by OblibSystems

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by vsa000
1

Using some Regex will do:

Dim text As String = "<td class=""bld""><span id=""ref_12590587_l"">5,304.48</span>"
Dim regularExpressionPattern As String = "\>(.*?)\<"
Dim re As New Regex(regularExpressionPattern)
Dim dec As Decimal
Dim str As String = ""
For Each m As Match In re.Matches(text)
    str = m.Value.Replace(">", "").Replace("<", "")
    If str.Length > 0 Then
        If str.Contains(",") Then
            str = str.Replace(",", "")
        End If
    End If
Next

Edited by Mitja Bonca

Votes + Comments
Good job, Mitja.
0
   Function GetValue() As String
    Dim str As String = "<td class= ""bld"" ><span id=""ref_12590587_l"">5,304.48</span>"
    Dim strIndex As Integer = str.LastIndexOf("""")
    Dim str_tmp As String = str.Substring(strIndex + 2)
    Dim lstIndex As Integer = str_tmp.LastIndexOf("<")
    Dim str_fnl As String = str_tmp.Substring(0, lstIndex)
    If str_fnl.Contains(",") Then
        str_fnl = str_fnl.Replace(",", "")
    End If
    Return str_fnl
   End Function

Edited by vsa000

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.