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

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)
commented: Nice :) +11