Reputation: 111
I need to remove a part of text extracted by imacros.
The text estracted can be change.
Example texts extracted by imacros:
THE FIRST SENTENCE - THE SECONDS SENTENCE
THE FIRST WORD - THE SECONDS WORD
THE FIRST NAME - THE SECONDS NAME
CACAO - COLA
I need to remove the part BEFORE - AND remove the part AFTER -
1° Eval script need to take:
THE FIRST SENTENCE
THE FIRST WORD
THE FIRST NAME
CACAO
2° Eval script need to take
THE SECONDS SENTENCE
THE SECONDS WORD
THE SECONDS NAME
COLA
I need with Eval to remove the part BEFORE - and remove the part AFTER - using 2 different eval script.
I use an eval javascript like this but I need to create a regex expression to remove only the part before and after - (spaces included)
SET !VAR1 EVAL("'{{!EXTRACT}}'.replace(/[\\TEXTTOREMOVE|TEXTTOREMOVE|TEXTTOREMOVE|TEXTTOREMOVE|TEXTTOREMOVE|]/g, '');")
SET !VAR2 EVAL("'{{!EXTRACT}}'.replace(/[\\TEXTTOREMOVE|TEXTTOREMOVE|TEXTTOREMOVE|TEXTTOREMOVE|TEXTTOREMOVE|]/g, '');")
Any suggestion please ?
Thanks
Upvotes: 0
Views: 1241
Reputation: 5299
In this case you can solve the issue without regular expressions:
SET !VAR1 EVAL("'{{!EXTRACT}}'.split('-')[0].trim();")
SET !VAR2 EVAL("'{{!EXTRACT}}'.split('-')[1].trim();")
Upvotes: 2