Select specific text from storetext value

hi, i want to separate out specific text from storetext value.

example:

i select a value by xpath selection on web page which is “3214 is the lucky number” or “5847 is the lucky number” which is stored by storetext command as the whole sentence but the numbers are varied during each loop.

is there any way to store “3214” or “5847” in the above example and omit “is the lucky number”

thanks in advance.

You can do this using javascript.

You may check https://www.w3schools.com/js/js_string_methods.asp for some string manipulation in Javascript and https://ui.vision/rpa/docs/selenium-ide/executescript#sandbox for how-to build and run javascript code.

Here one approach using substr, suposing all numbers are 4-digits long, beginning at position 0:

Command: storeValue
Target: xpath=yourFieldDescriptor
Value: myString

Command: executeScript_Sandbox
Target: return ${myString}.substr(0,4)
Value: myNumber

Command: echo
Target: My lucky number is ${myNumber}
Value:

1 Like

Thank you hectorbot for the wonderful solution. I was wondering whether there are other approaches too in such cases. Thanks again.