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
  • December 08, 2016, 12:09:12 PM
  • 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: possible regex search alias bug  (Read 2516 times)

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 858
    • View Profile
    • Donate to Member
possible regex search alias bug
« on: May 09, 2013, 09:05:23 AM »
Hi, I have a conflict with two aliases. To reproduce, make these two regex aliases:
^(.*)\s\s$

and
^aa((?: .*|))$
If I type "aa[space]" in FARR the first alias is mistakenly triggered. Is that a bug?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,412
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: possible regex search alias bug
« Reply #1 on: May 09, 2013, 11:18:56 AM »
strange.. can i ask if you haven't given a NAME to the first alias that might cause it being triggered?

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 858
    • View Profile
    • Donate to Member
Re: possible regex search alias bug
« Reply #2 on: May 09, 2013, 12:28:25 PM »
No this reproduces whatever name I set for it.

More testing: if I open the "edit group alias" window for the first alias and enter "aa " in the test box it (correctly) says "no match" in red text. But I enter "aa " (without quotation marks) in the regular FARR inputbox the first alias runs. Weird!

I tried tweaking the second alias into the below, but the problem is still there.
^aa( .*)$
edit:
hm, if I use this the problem also occurs
^aa(|.+)$
but if I use this there is no problem
^aa(| .+)$
A drawback is that with this last regex the alias first runs on "aa", then a regular FARR search is shown on "aa " and then the alias runs again on "aa test". I use this alias to on "aa" list all files in a folder and on "aa test" list all files in that folder matching the phrase test. Anyway, I don't understand why the problem appears in all but the last version of the regex.
« Last Edit: May 09, 2013, 12:38:51 PM by Nod5 »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,412
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: possible regex search alias bug
« Reply #3 on: May 09, 2013, 12:32:47 PM »
I cannot reproduce it.. i suspect the problem is caused by interaction with another alias.

Try this:

type "bb "

if this does not mistakenly trigger your first alias, then you know the problem is not with your first alias, but with some other interaction with ANOTHER alias triggering on the aa.

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 858
    • View Profile
    • Donate to Member
Re: possible regex search alias bug
« Reply #4 on: May 09, 2013, 12:46:23 PM »
"bb " does nothing. But what makes me think there is some issue with FARR here is that if I change the second alias from
^aa(|.+)$
to
^testing(|.+)$
I still have the problem i.e. "testing " triggers the first alias.

I have checked my list of aliases and found no third alias triggering on "aa" (nor on "testing"). Could this be related to the fact that the aa-alias is designed to trigger both on "aa" and on "aa whatever"?

Anyway, since
^aa(| .+)$
works good enough I'm by now just curious why there is a difference.

edit: Let me add that  the two aliases are used to launch these actions
^aa(|.+)$
aa | dosearch C:\test\ $$1

^(.*)\s\s$
dolaunch copyclip $$1 ;;; C:\ev2.exe
where ev2.exe is my workaround autohotkey script that passes a search to everything
« Last Edit: May 09, 2013, 01:08:12 PM by Nod5 »

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 858
    • View Profile
    • Donate to Member
Re: possible regex search alias bug
« Reply #5 on: May 09, 2013, 01:09:05 PM »
Aha! The problem is a space in the dosearch command string. If I change
aa | dosearch C:\test\ $$1
into
aa | dosearch C:\test\$$1
the problem is solved.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,412
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: possible regex search alias bug
« Reply #6 on: May 09, 2013, 01:20:03 PM »
I'm still a bit confused but it sounds like you are saying that what happened was the proper alias was triggered and then as it's action it replaced the search with text that immediately matched the other alias.

skajfes

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 231
    • View Profile
    • Donate to Member
Re: possible regex search alias bug
« Reply #7 on: May 10, 2013, 02:25:23 AM »
The problem is with the aa alias.
You are capturing the space with the search string.
So when you type in
aa[space]
FARR captures the space as $$1. Then in turn, you pass $$1 along to the result and have
dosearch C:\test\[space][space]
that triggers the other alias that matches on \s\s.

I think it is good practice not to capture the space before the parameters. There is less chance of bugs like this.
It is impossible to make anything foolproof because fools are so ingenious.

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 858
    • View Profile
    • Donate to Member
Re: possible regex search alias bug
« Reply #8 on: May 10, 2013, 10:32:46 AM »
mouser & skajfes: you are right, thank you for the explanation.  :Thmbsup:

skajfes: good practice in general - agreed! But in this particular case I wanted the alias to trigger first on "aa" (show all files in a folder) and on "aa somephrase" (show files in the folder matching "somephrase") *and* not switch back to a regular FARR search inbetween that. For that I needed the first space included in the match pattern.

skajfes

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 231
    • View Profile
    • Donate to Member
Re: possible regex search alias bug
« Reply #9 on: May 10, 2013, 11:43:40 AM »
If I understand you correctly you can write a regex like this with same effect:
^aa\s?(.*)$
It is impossible to make anything foolproof because fools are so ingenious.

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 858
    • View Profile
    • Donate to Member
Re: possible regex search alias bug
« Reply #10 on: May 10, 2013, 02:26:35 PM »
Yes, you're right, thanks! But why didn't I think of that?  :-[  :D

skajfes

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 231
    • View Profile
    • Donate to Member
Re: possible regex search alias bug
« Reply #11 on: May 11, 2013, 01:26:31 PM »
No problem. I use regex fairly often, so this is a simple problem for me :)

Btw, thanks for the donation  :Thmbsup:
It is impossible to make anything foolproof because fools are so ingenious.