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: possible regex search alias bug  (Read 8,392 times)

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
possible regex search alias bug
« on: May 09, 2013, 02:05 PM »
Hi, I have a conflict with two aliases. To reproduce, make these two regex aliases:
Code
^(.*)\s\s$ 
and
Code
^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: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: possible regex search alias bug
« Reply #1 on: May 09, 2013, 04:18 PM »
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: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
Re: possible regex search alias bug
« Reply #2 on: May 09, 2013, 05:28 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.
Code
^aa( .*)$
edit:
hm, if I use this the problem also occurs
Code
^aa(|.+)$
but if I use this there is no problem
Code
^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, 05:38 PM by Nod5 »

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: possible regex search alias bug
« Reply #3 on: May 09, 2013, 05:32 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: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
Re: possible regex search alias bug
« Reply #4 on: May 09, 2013, 05:46 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
Code
^aa(|.+)$
to
Code
^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
Code
^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
Code
^aa(|.+)$
aa | dosearch C:\test\ $$1

Code
^(.*)\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, 06:08 PM by Nod5 »

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
Re: possible regex search alias bug
« Reply #5 on: May 09, 2013, 06:09 PM »
Aha! The problem is a space in the dosearch command string. If I change
Code
aa | dosearch C:\test\ $$1
into
Code
aa | dosearch C:\test\$$1
the problem is solved.

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: possible regex search alias bug
« Reply #6 on: May 09, 2013, 06:20 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: 267
Re: possible regex search alias bug
« Reply #7 on: May 10, 2013, 07:25 AM »
The problem is with the aa alias.
You are capturing the space with the search string.
So when you type in
Code
aa[space]
FARR captures the space as $$1. Then in turn, you pass $$1 along to the result and have
Code
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: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
Re: possible regex search alias bug
« Reply #8 on: May 10, 2013, 03:32 PM »
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: 267
Re: possible regex search alias bug
« Reply #9 on: May 10, 2013, 04:43 PM »
If I understand you correctly you can write a regex like this with same effect:
Code
^aa\s?(.*)$
It is impossible to make anything foolproof because fools are so ingenious.

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
Re: possible regex search alias bug
« Reply #10 on: May 10, 2013, 07:26 PM »
Yes, you're right, thanks! But why didn't I think of that?  :-[  :D

skajfes

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 267
Re: possible regex search alias bug
« Reply #11 on: May 11, 2013, 06:26 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.

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