I was wondering if someone could show me how to extract part of string from a var in a Imacros java script.

WebPageNumber = "Code: ";
WebPageNumber += "TAB T=1" + NewLine;
WebPageNumber += "FRAME NAME="+"ext-comp-1006" + NewLine;
WebPageNumber += "TAG POS=1 TYPE=SPAN ATTR=ID:00B70000007Wo0i_paginator_rpp_target EXTRACT=TXT" + NewLine;
WebPageNumber +=  "SET !CLIPBOARD {{!EXTRACT}}";
PlayMacro = iimPlay(WebPageNumber);
alert (iimGetLastExtract ());

My Result is 1-75 of 75 Display 10 records per page Display 25 records per page Display 50 records per page Display 100 records per page Display 200 records per page

All I want to take from it is 1 & 75

有帮助吗?

解决方案

Since you're already using the JS implementation of iMacros, wouldn't it be easier just to manipulate that information with JS?

    var extractString = iimGetLastExtract();
    var firstNumber = extractString.substring(0,1);
    var secondNumber = extractString.substring(2,2);

That's assuming that you'll always be looking for the first number and the second pair of numbers. You can also use regular expressions with the JavaScript String match() method, but that'll dump an array of values.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top