|
Zafrusteria Wanderer
Joined: 11 Oct 2000 Posts: 94 Location: United Kingdom
|
Posted: Sat Dec 06, 2003 9:02 pm
%s in triggers not working with zero spaces |
V 6.62
Where the text can be :-
Align: [1000]
Align: [ 100]
Align: [ 10]
Align: [ 1]
I.e. there can be leading spaces but not always
trigger pattern is ^Align:%s~[%s(%d)~]$
The help says "%s match any amount of white space (spaces, tabs)
".
But when there are no leading spaces it does not match. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Dec 07, 2003 6:40 am |
That's correct. "Any amount" doesn't include zero. This is similar to %a (any amount of alphanumeric characters, but at least one), %d (any amount of digits, but at least one), %w (any amount of alphabetic characters, but at least one), etc. Almost all the wildcards work this way.
|
|
|
|
megamog75 Enchanter
Joined: 20 Nov 2002 Posts: 627 Location: USA
|
Posted: Sun Dec 07, 2003 10:14 am |
Are you ranting or do you want a fix?
here is your trigger that works:
#TRIGGER {Align: ~[(*)]} {"%1"}
or
#TRIGGER {Align: ~[(?)(?)(?)(?)]} {%1%2%3%4}
have fun |
|
|
|
Zafrusteria Wanderer
Joined: 11 Oct 2000 Posts: 94 Location: United Kingdom
|
Posted: Sun Dec 07, 2003 11:15 am |
No, I'm not ranting just pointing out something that is stated in the help that does not work as expected. In the hope it will get added to the FIXME list. Why is it that when the post is not vote for Zugg it is assumed to be an aimless rant?
The text in the help file is inconsistant where it is talking about "any number".
So atm, "any number" in the context of %s means one or more but in the context of * means zero or more? (same page of the help *boggle*).
I have a trigger that will fire the same as your first but that then adds the leading spaces to the captured data, which I do not want and therefore have to strip off. If %s works like * and could match on zero or more there would not be a problem.
Thanks for the replies, I'll go do some bending of my scripts to work around this. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Dec 07, 2003 12:34 pm |
Use %eval on the captured data to remove the spaces.
I think that %s was designed with that functionality from the start and it is the help file that should be corrected, or at least clarified. However, I couldn't say for sure. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Dec 07, 2003 6:43 pm |
Only megamog suggested it might be a rant, and even he didn't suggest it was aimless. I took it as a legitimate question and answered it. Why is it that when anyone doesn't immediately jump on your bandwagon you assume that everyone is being blindly loyal to Zugg?
* match any number (even none) of characters or white space
%s match any amount of white space (spaces, tabs)
(emphasis added)
If you consider this to be a bug, then by all means make a bug report either by email or on the Beta forum. I don't agree that the help file inconsistent, since it clearly indicates that * is different. But yes, at the moment "any number" in the context of %s means one or more but in the context of * (where it is specifically stated) means zero or more.
I'm sorry you don't like this and I can understand how in the particular case you cite a value of zero or more spaces would be desirable. However, in most cases people (myself, at least) use the specific wildcards when they actually want to ensure there will be a matching character of the specified type. When I use a pattern of "(%d)ma" I want it to match "27ma" (2 digits), and I DON'T want it to match "match" (0 digits), and I don't want to struggle to find a workaround because you had an isolated case where there might be zero spaces. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Dec 08, 2003 9:48 pm |
If you use the new 6.66a beta you can also convert your trigger to a regular expression and then use s* to match "zero or more" instead of the default of "one of more".
But Lightbulb is correct. The documentation is correct (even though it could be more specific) that "any number" does not include zero because this would cause all sorts of unwanted side effect behavior, like Lightbulb's example.
So, this isn't a bug and nothing will be changed, but the new version has a bit more flexibility with the regular expression stuff. |
|
|
|
|
|