How to remove last sentence in text with imacros eval using

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information:CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
Profinkonsults
Posts: 3
Joined: Mon Nov 02, 2015 6:46 am
Location: Vilnius, Lithuania
Contact:

How to remove last sentence in text with imacros eval using

Post by Profinkonsults » Fri Jul 13, 2018 12:48 pm

I tried to remove last sentence in extracted text using JavaScript replace method with regex. I check regex - it correct. But imacros default on code line which is right for most cases.

SET !VAR1 EVAL("var s=\'{{!EXTRACT}}\'; s.replace(/\.[^\.]+\.?$/,'.');"
chivracq
Posts: 8193
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to remove last sentence in text with imacros eval us

Post by chivracq » Fri Jul 13, 2018 2:29 pm

Profinkonsults wrote:I tried to remove last sentence in extracted text using JavaScript replace method with regex. I check regex - it correct. But imacros default on code line which is right for most cases.

Code: Select all

SET !VAR1 EVAL("var s=\'{{!EXTRACT}}\'; s.replace(/\.[^\.]+\.?$/,'.');"
CIM...! :mrgreen: (Read my Sig...)

But from a quick look, the Closing Bracket _)_ is missing at the end of your 'EVAL()'...
And _\'_ is incorrect as well..., you need to use _\"_ or simply _'_ but you cannot combine both together...
And 'EVAL()' usually needs to explicitly return the Result...
And if the Backward Slashes are part of the 'REGEXP', they probably need to be escaped...

>>>

+ Parallel Thread on SOF:
- How to remove last sentence in text with imacros eval using regex
(No Replies...)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Post Reply