Remove last 4 characters from input text field

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.

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:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

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.

Remove last 4 characters from input text field

by TaAaZZ on Mon May 16, 2016 10:12 am

Hi! I am fairly new to iMacros. I am using iMacros to extract some text from title of the page then paste that text in a text box. Currently when I put that extracted text, it gets .mp4 written in it (title contains .mp4). I want to remove '.mp4' and replace it with '.com'
Currently I am doing this:

Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:videoedit_title EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=1 TYPE=TEXTAREA FORM=NAME:NoFormName ATTR=ID:videoedit_description CONTENT="{{!VAR2}}.com"
wait seconds=2


This adds .com to the end but there is no code to remove .mp4

Any help would be appreciated. Thanks.
TaAaZZ
 
Posts: 1
Joined: Mon May 16, 2016 10:06 am

Re: Remove last 4 characters from input text field

by chivracq on Mon May 16, 2016 11:24 am

TaAaZZ wrote:Hi! I am fairly new to iMacros. I am using iMacros to extract some text from title of the page then paste that text in a text box. Currently when I put that extracted text, it gets .mp4 written in it (title contains .mp4). I want to remove '.mp4' and replace it with '.com'
Currently I am doing this:

Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:NoFormName ATTR=ID:videoedit_title EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=1 TYPE=TEXTAREA FORM=NAME:NoFormName ATTR=ID:videoedit_description CONTENT="{{!VAR2}}.com"
wait seconds=2


This adds .com to the end but there is no code to remove .mp4

Any help would be appreciated. Thanks.

CIM...! :mrgreen: (Always mention your FCI when you open a Thread, read my Sig, many Commands are not implemented for all Browsers/Versions...)

For your Qt, yep, simply use 'EVAL()' and 'replace()'...
- (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...
chivracq
 
Posts: 6477
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Remove last 4 characters from input text field

by IrishMacro on Tue May 17, 2016 2:44 am

Yup EVAL replace
As an example, this will go to http://wiki.imacros.net/EVAL and tag "Random wait" and replaces "wait" with a space, leaving just "Random"

URL GOTO=http://wiki.imacros.net/EVAL
TAG POS=1 TYPE=H4 ATTR=TXT:Random<SP>wait EXTRACT=TXT
SET !VAR1 EVAL("var variable=\"{{!EXTRACT}}\"; variable.replace(/wait/g,''); ")
PROMPT {{!VAR1}}
Firefox free plugin, last version
Win7
IrishMacro
 
Posts: 135
Joined: Wed Nov 03, 2010 5:27 am

Re: Remove last 4 characters from input text field

by chivracq on Tue May 17, 2016 3:57 am

IrishMacro wrote:Yup EVAL replace
As an example, this will go to http://wiki.imacros.net/EVAL and tag "Random wait" and replaces "wait" with a space, leaving just "Random"

Code: Select all
URL GOTO=http://wiki.imacros.net/EVAL
TAG POS=1 TYPE=H4 ATTR=TXT:Random<SP>wait EXTRACT=TXT
SET !VAR1 EVAL("var variable=\"{{!EXTRACT}}\"; variable.replace(/wait/g,''); ")
PROMPT {{!VAR1}}

Hum..., this is not really helping the OP to improve a bit their Skills with iMacros, I had deliberately only mentioned the Commands they can use for them to find the Solution by themselves by searching the Forum and the Wiki a little bit, they will never learn to solve Pb's by themselves otherwise... But OK, never mind, I guess I'm out of here... :roll:
(And there is an easier Syntax btw, but OK, nvm...)
- (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...
chivracq
 
Posts: 6477
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Data Extraction and Web Screen Scraping

Who is online

Users browsing this forum: No registered users and 3 guests

-->