0

Hi all,

I'm hoping someone can help out with this one.

I'm reading in an xml file, which is working fine with no problems, but I want to re-format one of the elements data attributes slightly.

The XML attribute output is currently

Wind: NW at 6 mph

What I want to do is extract just the number from the string, I figured an easy way would be to simply play with the length of the string and assign it to another variable.

However, I've ran into a little problem.

I can use

windRtrim = wind.Substring(0, wind.Length - 4)

(Where windRtrim is the amended string variable and wind is the string from above)

This returns

Wind: NW at 6

Which is great, but the problem now is trimming the correct number of characters from the beginning of the string as it'll be different if the number were to go over 9 (ie. 10 and above)

Does anyone have any ideas?

Thanks
TheMightySpud

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by GeekByChoiCe
1

small example:

Dim str As String = "NW at 6 mph"
Dim reg As New Text.RegularExpressions.Regex("[0-9]{1,}")
Debug.WriteLine(reg.Match(str).Value)
Votes + Comments
Nice :)
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.