Copy to clip board only whats between AAA and BBB

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
mykeasaurus
Newbie
Posts: 7
Joined: Thu Sep 01, 2005 2:10 am

Copy to clip board only whats between AAA and BBB

Post by mykeasaurus » Wed Oct 26, 2005 8:37 am

I was wondering if there was a way to copy just what is between two things?

Example, Is there a way to copy everything between all the AAA's and BBB's?

Hello AAAcopythisBBB nothing test AAAcopythistooBBB
Text text text AAAcopy this textBBB


Ive already got a script to take whatever is copied and insert it into a text file, so the text file would include:

copythis
copythistoo
copy this text


Let me know! :):)

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Oct 26, 2005 9:21 am

I think the easiest way to do it is the other way around - think about this differently. It will be easier to make Macro Scheduler copy ALL the text but THEN remove just the bit you need. The following code will remove each item from between the AAA/BBB tags:

Let>STARTTAG=AAA
Let>ENDTAG=BBB

//some text to test with - this could be retrieved from clipboard (GetClipBoard)
Let>text=Hello AAAcopythisBBB nothing test AAAcopythistooBBBText text text AAAcopy this textBBB

Label>Parser
Let>item={copy(%text%,Pos(%STARTTAG%,%text%)+Length(%STARTTAG%),Length(%text%))}
Let>item={copy(%item%,1,Pos(%ENDTAG%,%item%)-1)}

//Do what you need with item here:
MessageModal>item

Let>text={copy(%text%,Pos(%ENDTAG%,%text%)+Length(%ENDTAG%),Length(%text%))}
Let>ps={Pos(%STARTTAG%,%text%)}
If>ps>0,Parser


You can run the above example without modification and it will pop up a message box for each item you want extracted. Try it.
MJT Net Support
[email protected]

mykeasaurus
Newbie
Posts: 7
Joined: Thu Sep 01, 2005 2:10 am

Post by mykeasaurus » Wed Oct 26, 2005 11:58 am

I think either I didnt explain myself well enough or I dont understand if what you wrote works. Let me explain again.

I've got a notepad file with tons and tons of code. Within the notepad file are pieces of code like this: test/1111/folder. "1111" being a random number that changes throughout the text file. I need to go through the text file and find everything between every instance of "test/" and "/folder" and paste it to a notepad file.

I hope this makes more sense. Or let me know that I'm dumb and you already told me the solution. :)

Thanks!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Wed Oct 26, 2005 12:10 pm

Yes, I did understand you and my example works. The code I provided shows how to extract items between two placeholders. Please take another look at my example. You can use that code to achieve your goal.
MJT Net Support
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts