How to extract numeric value from captured text

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
sachinpuranik
Newbie
Posts: 7
Joined: Thu Feb 18, 2016 9:58 am

How to extract numeric value from captured text

Post by sachinpuranik » Wed Aug 02, 2017 2:37 pm

Hi All,
I need to extract numeric value from captured text through macro script.Can anyone from this forum help me out in this.

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: How to extract numeric value from captured text

Post by JRL » Wed Aug 02, 2017 6:59 pm

So you need to parse the text to extract a particular segment, in your case you want a number. To help we'd need to have a good idea of what the text looks like. Parsing is very specific to the text string being evaluated.

zabros2020
Pro Scripter
Posts: 70
Joined: Sun May 03, 2009 11:49 pm
Location: AU

Re: How to extract numeric value from captured text

Post by zabros2020 » Wed Aug 09, 2017 4:26 am

Agree with JRL.

You could parse using regex as starting point with something like this:

Code: Select all

Let>string=test_#getThis123_andThis456number#only from string
Let>pattern=[+\d ]*
RegEx>%pattern%,%string%,0,arrM,numM,0
Let>i=0
Let>sTmp=
If>numM>0
    Repeat>i
        Add>i,1
        Concat>sTmp,arrM_%i%
    Until>i=%numM%
EndIf
MessageModal>%sTmp%
Loving MS's Capabilities!!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts