[Request] - simple search an replace in string

Sharing and discussing custom actions for LaunchBar
ben
Posts: 2
Joined: Thu Aug 06, 2015 7:14 am

[Request] - simple search an replace in string

Postby ben » Thu Aug 06, 2015 7:22 am

Hi,

replaced spotlight with LB and added a few plugins.

Now I need a custom action that do a simple search and replace within a url (or text):
I would like to change the source url (http://Domain1.de/Test -> http://domain2.de/Test) to the destination url, where the rest of the url will be preserved

Unfortunately, I'm no expert in programming and I couldn't create this by myself.
I tried a few JavaScript functions, works on html but not in LB.http://www.w3schools.com/jsref/jsref_replace.asp

Would be great if anyone can help me or maybe there is a similar script that already exists, that could be used as an example!?

regards ben

raguay
Rank 1
Rank 1
Posts: 32
Joined: Fri Jul 18, 2014 11:08 am

Re: [Request] - simple search an replace in string

Postby raguay » Thu Aug 06, 2015 8:49 am

Hi Ben,

I did a quick hack script for what you are asking. It requires you to create a regular expression to pull out the context around the domain name and then paste it all back together again. You can use this as an example to make other scripts that do specific text changes like this. You can download it from my DropBox: https://db.tt/1Cs8QgHa

Richard

ben
Posts: 2
Joined: Thu Aug 06, 2015 7:14 am

Re: [Request] - simple search an replace in string

Postby ben » Fri Aug 07, 2015 12:44 pm

Hi Richard,

thank you, the regex is woking perfectly, right now I'm struggling a bit with the combination auf the url, but most was done by you, thanks!

raguay
Rank 1
Rank 1
Posts: 32
Joined: Fri Jul 18, 2014 11:08 am

Re: [Request] - simple search an replace in string

Postby raguay » Sat Aug 08, 2015 1:33 pm

Hi Ben,

Glad it was helpful.


Return to “LaunchBar Actions”

Who is online

Users browsing this forum: No registered users and 3 guests