Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to get only numeric values from text
#6
Solved: 11 Years, 4 Months ago
you could also use regular expressions to represent your string. The regular expression below says to look for the string "RS", followed by a decimal characters (.), followed by zero or more numeric digits followed by zero or more decimal characters, followed by zero or more digits. The parentheses enclose the part of the regular expression that you want to keep (it stores it in Matches(0).SubMatches(0) in this example). The resulting string is everything but "RS" at the beginning of the string and the trailing "/-" string.


Code:
Dim regEx, Matches, returnString   ' Create variable.
   Set regEx = New RegExp   ' Create a regular expression.
   regEx.Pattern = "RS\.*(\d+\.*\d*)/-" ' Set pattern
   regEx.IgnoreCase = True   ' Set case insensitivity.
   regEx.Global = True   ' Set global applicability.

    strng="Rs.4500.00/-"
    'strng="RS340067.23/-"

   Set Matches = regEx.Execute(strng)   ' Execute search.
   If Matches.Count=1 Then
       If Matches(0).SubMatches.count=1 Then
       End If
       returnString=Matches(0).Submatches(0)
   End If

msgbox returnString

set regEx=nothing
Reply


Messages In This Thread
RE: how to get only numeric values from text - by tdevick - 03-10-2011, 03:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to Validate Text filed is blank after clicking on the Text box balak89 3 4,905 09-13-2015, 12:06 AM
Last Post: ADITI1992
  Validate Numeric value is displaying expected format kalaivanan123 1 3,508 09-23-2013, 08:45 PM
Last Post: ravi.gajul
  I am trying to extract text from a webelement but it is generating blank text scenari excellentpawan 2 4,674 08-13-2013, 08:37 PM
Last Post: excellentpawan
  how to pass a numeric value into webedit silpavinod 3 3,867 10-15-2012, 01:57 PM
Last Post: silpavinod
  Need help on numeric value display AutomationTester2011 3 3,222 07-19-2011, 05:40 PM
Last Post: rajpes

Forum Jump:


Users browsing this thread: 4 Guest(s)