Using EVAL and .match to edit extracted source code

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:


Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Using EVAL and .match to edit extracted source code

by Riss on Thu Mar 21, 2013 9:47 pm


I'm hoping someone can help... I've searched this forum as well as Google looking for info that could assist me with my problem which has got me this far but now I need some guidance which is specific to my project.

I'm using the following code to extract the page source code;
Code: Select all

The result returned is this; All I want is the Number contained in the 'Value' tag, in this example 164033.
<td onmouseout="Tables.unSelectRow(this);" onmouseover="Tables.selectRow(this);" style="text-align: center; border-color: rgb(0, 0, 255); border-width: 2px; border-style: solid;"><input name="segmentsToAllocate" id="segmentsToAllocate" value="164033" onclick="SegmentsToAllocate.toggleSelectCostingSegment(this, true, true, SegmentsToAllocate.getInvoiceHeaderColumnPosition(), false); SegmentsToAllocate.calculateSummaryTotals();" type="checkbox"></td>

I thought to use the EVAL function but I am struggling with the JavaScript component of this. At the moment my code is this:
Code: Select all
SET !VAR1 EVAL("var s='{{!EXTRACT}}'; s.match(/value=+(.+?)[^0-9]/);")

I think I'm close as the result I'm getting is
but I'm not there yet... Can anyone out there please help?
Posts: 8
Joined: Mon Jan 23, 2012 5:36 pm

Re: Using EVAL and .match to edit extracted source code

by Edoctoor on Sat Dec 05, 2015 11:29 am

I know it is an old post... but for anyone that still wants an answer

SET !VAR1 EVAL("var s='{{!EXTRACT}}'; s.match(/value=+(.+?)[^0-9]/); s[0]")
iMacros Version
Browser FireFox 42.0
OS Windows 7 Home Premium - Service Pack 1

Before starting a topic please read the following; thank you!
User avatar
Posts: 34
Joined: Sun Nov 29, 2015 12:53 pm

Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 3 guests