Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • October 22, 2017, 01:28 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: [Solved] Multiple parameters to URL?  (Read 4274 times)

vbmark

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 40
    • View Profile
    • Donate to Member
[Solved] Multiple parameters to URL?
« on: November 03, 2013, 07:32 AM »
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, 07:17 AM by vbmark »

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 864
    • View Profile
    • Donate to Member
Re: Multiple parameters to URL?
« Reply #1 on: November 03, 2013, 04:17 PM »
Make a new alias called "car"
Under Regular Expression Pattern put
^car (.*)$
and under results put
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: 37,495
    • View Profile
    • Donate to Member
Re: Multiple parameters to URL?
« Reply #2 on: November 03, 2013, 04: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
  • *
  • default avatar
  • Posts: 40
    • View Profile
    • Donate to Member
Re: Multiple parameters to URL?
« Reply #3 on: November 03, 2013, 08:17 PM »
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 03, 2013, 08:27 PM by vbmark »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 37,495
    • View Profile
    • Donate to Member
Re: Multiple parameters to URL?
« Reply #4 on: November 03, 2013, 08:33 PM »
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
  • *
  • default avatar
  • Posts: 40
    • View Profile
    • Donate to Member
Re: Multiple parameters to URL?
« Reply #5 on: November 04, 2013, 06:38 AM »
Sweet! Capture groups worked. And the testing place is great.

Thanks!!

vbmark

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 40
    • View Profile
    • Donate to Member
Re: [Solved] Multiple parameters to URL?
« Reply #6 on: November 04, 2013, 07:27 AM »
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: 250
    • View Profile
    • Donate to Member
Re: [Solved] Multiple parameters to URL?
« Reply #7 on: November 04, 2013, 08:16 AM »
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?

vbmark

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 40
    • View Profile
    • Donate to Member
Re: [Solved] Multiple parameters to URL?
« Reply #8 on: November 04, 2013, 08:36 AM »
What did you put in regex?

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

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 37,495
    • View Profile
    • Donate to Member
Re: [Solved] Multiple parameters to URL?
« Reply #9 on: November 04, 2013, 11:11 AM »
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,038
    • View Profile
    • Donate to Member
Re: [Solved] Multiple parameters to URL?
« Reply #10 on: November 04, 2013, 12:09 PM »
Should be \w* instead of .* within the round braces

wjamoe

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 90
    • View Profile
    • Donate to Member
Re: [Solved] Multiple parameters to URL?
« Reply #11 on: November 05, 2013, 12: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,038
    • View Profile
    • Donate to Member
Re: [Solved] Multiple parameters to URL?
« Reply #12 on: November 05, 2013, 01: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:
^car (\w*)\s*(\w*)\s*:?\s*(\w*)
This way you can even have 0 or more spaces around the colon.

vbmark

  • Participant
  • Joined in 2005
  • *
  • default avatar
  • Posts: 40
    • View Profile
    • Donate to Member
Re: [Solved] Multiple parameters to URL?
« Reply #13 on: November 05, 2013, 05: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:
^car (\w*)\s*(\w*)\s*:?\s*(\w*)
This way you can even have 0 or more spaces around the colon.

Good stuff!  Thanks!