DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: [Solved] Multiple parameters to URL?  (Read 13,905 times)

vbmark

  • Participant
  • Joined in 2005
  • *
  • Posts: 44
[Solved] Multiple parameters to URL?
« on: November 03, 2013, 01:32 PM »
I'm having some trouble with this custom Alias.

In FARR I want to be able to type something like this:

car ford fusion:2007

And have the results go to something like, for example...

http://www.car.com/q=ford+fusion%3a2007

I just can't figure out how to do the multiple parameters.

Thanks!

« Last Edit: November 04, 2013, 01:17 PM by vbmark »

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
Re: Multiple parameters to URL?
« Reply #1 on: November 03, 2013, 10:17 PM »
Make a new alias called "car"
Under Regular Expression Pattern put
Code
^car (.*)$
and under results put
Code
car $$1|http://www.car.com/q=$$1
Then click Ok.

Type "car ford fusion:2007" in FARR to launch http://www.car.com/q=ford fusion:2007
Spaces isn't replaced with plus signs in the search but it may still work.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: Multiple parameters to URL?
« Reply #2 on: November 03, 2013, 10:23 PM »
It may work exactly as Nod5 says, but you can also use
You can use $$u1 instead of $$1 to have FARR urlencode the spaces and special characters when doing a web search.

vbmark

  • Participant
  • Joined in 2005
  • *
  • Posts: 44
Re: Multiple parameters to URL?
« Reply #3 on: November 04, 2013, 02:17 AM »
Using $$u1 was what I needed to make it work how I wanted.  Thanks for that.

However, once I tried that, I see now that what I really need is for this:

car ford fusion:2007

to be turned into this:

...bla.com/?make=ford&model=fusion&year=2007

Is there a way to transform that FARR command into those parameters?

« Last Edit: November 04, 2013, 02:27 AM by vbmark »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: Multiple parameters to URL?
« Reply #4 on: November 04, 2013, 02:33 AM »
yep, you just need a regex with multiple capture groups.  see if you can figure it out, if not someone good at regex will be able to post a solution.

note that the farr alias group configuration where you specify the regular expression has a place where you can test things out -- you can use that to experiment.

vbmark

  • Participant
  • Joined in 2005
  • *
  • Posts: 44
Re: Multiple parameters to URL?
« Reply #5 on: November 04, 2013, 12:38 PM »
Sweet! Capture groups worked. And the testing place is great.

Thanks!!

vbmark

  • Participant
  • Joined in 2005
  • *
  • Posts: 44
Re: [Solved] Multiple parameters to URL?
« Reply #6 on: November 04, 2013, 01:27 PM »
One other question.  When I use the Test place with capture groups the results box shows $$1= | $$2= | $$3=

Everything seems to go into $$1. What is the purpose of the other ones?

Thanks.

skajfes

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 267
Re: [Solved] Multiple parameters to URL?
« Reply #7 on: November 04, 2013, 02:16 PM »
The other ones ($$2 and $$3) are also capture groups, but what is actually captured depends on your regex. What did you put in regex?
It is impossible to make anything foolproof because fools are so ingenious.

vbmark

  • Participant
  • Joined in 2005
  • *
  • Posts: 44
Re: [Solved] Multiple parameters to URL?
« Reply #8 on: November 04, 2013, 02:36 PM »
What did you put in regex?

^test (.*)\s?(.*)?:?(.*)?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: [Solved] Multiple parameters to URL?
« Reply #9 on: November 04, 2013, 05:11 PM »
Quote
Everything seems to go into $$1
then your regex is wrong, and you aren't capturing the different components into the different groups.

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: [Solved] Multiple parameters to URL?
« Reply #10 on: November 04, 2013, 06:09 PM »
Should be \w* instead of .* within the round braces
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

wjamoe

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 99
    • Participated in NANY Challenge Once
    • Plugin Coding Medal
Re: [Solved] Multiple parameters to URL?
« Reply #11 on: November 05, 2013, 06:46 AM »
if you define alias trigger (if you leave out the colon you should also leave it out of the regex)

  car make model:year

and define regex as car at the beginning of the line followed by two words separated by a single space followed by a  colon and a third word

  ^car (.*) (.*):(.*)

results where $$1 substitues the first word matching (.*)

  http://www.car.com/?make=$$1&model=$$2&year=$$3

or alternatively from your original request:
  http://www.car.com/q=$$1+$$2%3a$$3

when you type
 
  car ford fusion:2009

it turns into
  http://www.car.com/?make=ford&model=fusion&year=2009

or when you use the alternative
  http://www.car.com/q=ford+fusion%3a2009

(BTW www.car.com does not work with these paramaters?)


Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: [Solved] Multiple parameters to URL?
« Reply #12 on: November 05, 2013, 07:40 AM »
 ^car (.*) (.*):(.*)

results where $$1 substitues the first word matching (.*)
This only works when typing exactly 1 space after the first word.

A more reliable regex for capturing separate words, independent from the number of spaces, would be:
Code
^car (\w*)\s*(\w*)\s*:?\s*(\w*)
This way you can even have 0 or more spaces around the colon.
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

vbmark

  • Participant
  • Joined in 2005
  • *
  • Posts: 44
Re: [Solved] Multiple parameters to URL?
« Reply #13 on: November 05, 2013, 11:48 AM »
(BTW www.car.com does not work with these paramaters?)

That domain was just an example.

A more reliable regex for capturing separate words, independent from the number of spaces, would be:
Code
^car (\w*)\s*(\w*)\s*:?\s*(\w*)
This way you can even have 0 or more spaces around the colon.

Good stuff!  Thanks!

Original address: https://www.donationcoder.com/forum/index.php?topic=36461.0