! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Ambiguous behavior of action regexp
Status:
CLOSED: FIXED
Product:
Xfce4-clipman-plugin
Component:
General

Comments

Description Adrien CLERC 2009-09-06 10:35:49 CEST
Hi,

I've just installed xfce4-clipman and xfce4-clipman-plugin from debian unstable repository. I've decided to start using action, especially the built-in "bug".
I've changed the pattern to "#([0-9]+)".

This pattern doesn't match the following snippets :
closes: #519165
… and any other variants

But it does match the following ones :
#519165
#519165.
#519165 and some example values

This is ambiguous : there is no "^" at the beginning, but if the selected text doesn't start with the pattern, it doesn't raise the popup menu. However, there's no "$" at the end but it matches values that don't end with the defined pattern.

We should fine a clean way to handle this, or it will confuse users.
Comment 1 Mike Massonnet editbugs 2009-09-06 10:54:25 CEST
There is a voluntary regex flag G_REGEX_ANCHORED, from the API:

The pattern is forced to be "anchored", that is, it is constrained to match only at the first matching point in the string that is being searched. This effect can also be achieved by appropriate constructs in the pattern itself such as the "^" metacharater. 

You can put '.*' in front or in the end. The reason is that doing matches with anchors at the beginning and the end may trigger unwished menu popups on long or very long text selections.

What if I put the extra ^$ around the text entry to make it more clear in that case?
Comment 2 Adrien CLERC 2009-09-06 11:14:57 CEST
I'm in front of a dilemma :)

First, I'm used to use regexps, so I really know how to use ^ and $, and why they should be extensively used. If I have to fill a regexp field, I fill it with those metacharacters (or not) and get the expected results.

However, for this particular use, I know that I will always want them. And it will be much simpler for the simple user who's not a regexp guru.

So I think that yes, you should write the fact the pattern is automatically wrapped inside ^ and $. Maybe it could be useful to write down that adding ".*" could bypass this thing, but I'm not sure it's really useful. Power users will obviously know this, and simple users just want to match simple snippets.
Comment 3 Mike Massonnet editbugs 2009-09-17 19:29:49 CEST
I pushed a change within the glade file to inform about the anchor flag.

Bug #5736

Reported by:
Adrien CLERC
Reported on: 2009-09-06
Last modified on: 2012-04-09

People

Assignee:
Mike Massonnet
CC List:
0 users

Version

Version:
unspecified

Attachments

Additional information