I am very new to coding so forgive my ignorance and thanks for any help in advance!
I am using the command “Store text” and selecting the target. Then using a variable to store the text for later use. Everything works, but because the target returns more text than I need, I’m not sure what to do.
Example: There is a section on a webpage that says “Estimate Code: DS4582” That is one string in the target. I am only needing the number after the "Estimate Code: " part. So basically I am trying to extract just the DS4582 but cant seem to figure out how.
I have tried to use extract but that didnt work either. Any ideas?
Thanks, the text that is originally stored will change every time the macro is ran. Here is the code. It says line 2 error * Error in runEval code: Invalid or unexpected token.
Basically, i want the alphanumeric code after the “estimate code:” copied to the clipboard so i can paste (type) it in another section.
{
“Name”: “copy estimate code”,
“CreationDate”: “2019-1-31”,
“Commands”: [
{
“Command”: “storeText”,
“Target”: “//*[@id=“quoteOverlayDomId”]/div[2]/div[5]”,
“Value”: “t”
},
{
“Command”: “storeEval”,
“Target”: “s1 = \”${t}\"; r = s1.split (\":\"); var s2 = r[1]; s2",
“Value”: “t”
},
{
“Command”: “echo”,
“Target”: “t=${t}”,
“Value”: “”
}
]
}
“Error in runEval code: Invalid or unexpected token.” => Maybe your extracted strings contains line breaks? Then use first this to remove the line breaks:
a = storedVars['t']; a = a.replace(/(\n|\r)/gm, ""); a
I copied this line from the DemoPDFTest_with_OCR macro that ships with Kantu.