* [9fans] regexp doubt
@ 2010-07-13 14:56 hugo rivera
2010-07-13 15:01 ` Vinu Rajashekhar
` (2 more replies)
0 siblings, 3 replies; 20+ messages in thread
From: hugo rivera @ 2010-07-13 14:56 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Hi,
can someone tell me why the regular expression /stat[abc]?[ ;\-]/
doesn't match the string "stat-" in acme? I expect it to match, where
does my mistake lie?
Saludos,
--
Hugo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 14:56 [9fans] regexp doubt hugo rivera
@ 2010-07-13 15:01 ` Vinu Rajashekhar
2010-07-13 15:11 ` hugo rivera
2010-07-13 15:15 ` Rodolfo (kix)
2010-07-13 15:18 ` erik quanstrom
2010-07-13 15:48 ` yy
2 siblings, 2 replies; 20+ messages in thread
From: Vinu Rajashekhar @ 2010-07-13 15:01 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
[-- Attachment #1: Type: text/plain, Size: 360 bytes --]
On Tue, Jul 13, 2010 at 8:26 PM, hugo rivera <uair00@gmail.com> wrote:
> Hi,
> can someone tell me why the regular expression /stat[abc]?[ ;\-]/
> doesn't match the string "stat-" in acme? I expect it to match, where
> does my mistake lie?
> Saludos,
>
> It's the [abc]? I guess, it says that you want an a, b, or c after stat.
> --
> Hugo
>
>
[-- Attachment #2: Type: text/html, Size: 772 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 15:01 ` Vinu Rajashekhar
@ 2010-07-13 15:11 ` hugo rivera
2010-07-13 15:15 ` Rodolfo (kix)
1 sibling, 0 replies; 20+ messages in thread
From: hugo rivera @ 2010-07-13 15:11 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
2010/7/13 Vinu Rajashekhar <vinutheraj@gmail.com>:
>
> On Tue, Jul 13, 2010 at 8:26 PM, hugo rivera <uair00@gmail.com> wrote:
> It's the [abc]? I guess, it says that you want an a, b, or c after stat.
not really, since there's a '?' REP operator there. And it actually
matches strings like "stat;"
--
Hugo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 15:01 ` Vinu Rajashekhar
2010-07-13 15:11 ` hugo rivera
@ 2010-07-13 15:15 ` Rodolfo (kix)
2010-07-13 15:31 ` hugo rivera
1 sibling, 1 reply; 20+ messages in thread
From: Rodolfo (kix) @ 2010-07-13 15:15 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Can you try:
/stat[abc]?[ ;\\-]/
I am not sure (and I do not have acme here), but probably the problem
is with the backslash.
You can try this too:
/stat[abc]?[ ;-]/
Saludos.
On Tue, Jul 13, 2010 at 5:01 PM, Vinu Rajashekhar <vinutheraj@gmail.com> wrote:
>
> On Tue, Jul 13, 2010 at 8:26 PM, hugo rivera <uair00@gmail.com> wrote:
>>
>> Hi,
>> can someone tell me why the regular expression /stat[abc]?[ ;\-]/
>> doesn't match the string "stat-" in acme? I expect it to match, where
>> does my mistake lie?
>> Saludos,
>>
> It's the [abc]? I guess, it says that you want an a, b, or c after stat.
>>
>> --
>> Hugo
>>
>
>
--
Rodolfo García "kix"
http://www.kix.es/ ham: EA4ERH @ IN80ER
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 14:56 [9fans] regexp doubt hugo rivera
2010-07-13 15:01 ` Vinu Rajashekhar
@ 2010-07-13 15:18 ` erik quanstrom
2010-07-13 15:31 ` hugo rivera
2010-07-13 15:48 ` yy
2 siblings, 1 reply; 20+ messages in thread
From: erik quanstrom @ 2010-07-13 15:18 UTC (permalink / raw)
To: 9fans
On Tue Jul 13 11:13:03 EDT 2010, uair00@gmail.com wrote:
> Hi,
> can someone tell me why the regular expression /stat[abc]?[ ;\-]/
> doesn't match the string "stat-" in acme? I expect it to match, where
> does my mistake lie?
> Saludos,
if you are doing a b3 search, you want
:/stat[abc]?[ ;\-]/
just the leading : is missing.
- erik
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 15:15 ` Rodolfo (kix)
@ 2010-07-13 15:31 ` hugo rivera
2010-07-13 15:37 ` blstuart
0 siblings, 1 reply; 20+ messages in thread
From: hugo rivera @ 2010-07-13 15:31 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
both of them yield a
regexp: malformed `[]'
error.
I forgot to mention and I had an alternative solution from the
beginning /stat[abc]?([ ;]|-)/
I'm just wondering the reason the original version failed.
2010/7/13 Rodolfo (kix) <kix@kix.es>:
> Can you try:
>
> /stat[abc]?[ ;\\-]/
>
> I am not sure (and I do not have acme here), but probably the problem
> is with the backslash.
>
> You can try this too:
>
> /stat[abc]?[ ;-]/
>
--
Hugo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 15:18 ` erik quanstrom
@ 2010-07-13 15:31 ` hugo rivera
2010-07-13 16:00 ` erik quanstrom
0 siblings, 1 reply; 20+ messages in thread
From: hugo rivera @ 2010-07-13 15:31 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
I wasn't searching, but using it with acme's x command.
2010/7/13 erik quanstrom <quanstro@labs.coraid.com>:
> On Tue Jul 13 11:13:03 EDT 2010, uair00@gmail.com wrote:
>> Hi,
>> can someone tell me why the regular expression /stat[abc]?[ ;\-]/
>> doesn't match the string "stat-" in acme? I expect it to match, where
>> does my mistake lie?
>> Saludos,
>
> if you are doing a b3 search, you want
>
> :/stat[abc]?[ ;\-]/
>
> just the leading : is missing.
>
> - erik
>
>
--
Hugo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 15:31 ` hugo rivera
@ 2010-07-13 15:37 ` blstuart
2010-07-13 15:46 ` hugo rivera
2010-07-13 15:50 ` Ethan Grammatikidis
0 siblings, 2 replies; 20+ messages in thread
From: blstuart @ 2010-07-13 15:37 UTC (permalink / raw)
To: 9fans
> both of them yield a
>
> regexp: malformed `[]'
>
> error.
> I forgot to mention and I had an alternative solution from the
> beginning /stat[abc]?([ ;]|-)/
> I'm just wondering the reason the original version failed.
As I recall, if you're going to include a hyphen in a character
class, it has to be the first character so that it isn't taken to
indicate a range.
BLS
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 15:37 ` blstuart
@ 2010-07-13 15:46 ` hugo rivera
2010-07-13 15:50 ` Ethan Grammatikidis
1 sibling, 0 replies; 20+ messages in thread
From: hugo rivera @ 2010-07-13 15:46 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
maybe I'm using a buggy version of acme, because /stat[abc]?[- ;]/
also fails with a "malformed" error. And according to the regexp(7)
man page, you should be able to precede a '-' with a backslash.
2010/7/13 <blstuart@bellsouth.net>:
>> both of them yield a
>>
>> regexp: malformed `[]'
>>
>> error.
>> I forgot to mention and I had an alternative solution from the
>> beginning /stat[abc]?([ ;]|-)/
>> I'm just wondering the reason the original version failed.
>
> As I recall, if you're going to include a hyphen in a character
> class, it has to be the first character so that it isn't taken to
> indicate a range.
>
> BLS
>
>
>
--
Hugo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 14:56 [9fans] regexp doubt hugo rivera
2010-07-13 15:01 ` Vinu Rajashekhar
2010-07-13 15:18 ` erik quanstrom
@ 2010-07-13 15:48 ` yy
2 siblings, 0 replies; 20+ messages in thread
From: yy @ 2010-07-13 15:48 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
2010/7/13 hugo rivera <uair00@gmail.com>:
> Hi,
> can someone tell me why the regular expression /stat[abc]?[ ;\-]/
> doesn't match the string "stat-" in acme? I expect it to match, where
> does my mistake lie?
> Saludos,
>
> --
> Hugo
>
>
It works here (both with B3 searches and Edit ,x commands). Maybe what
you have in your text is an unicode dash?
--
- yiyus || JGL . 4l77.com
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 15:37 ` blstuart
2010-07-13 15:46 ` hugo rivera
@ 2010-07-13 15:50 ` Ethan Grammatikidis
1 sibling, 0 replies; 20+ messages in thread
From: Ethan Grammatikidis @ 2010-07-13 15:50 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
On 13 Jul 2010, at 16:37, blstuart@bellsouth.net wrote:
>> both of them yield a
>>
>> regexp: malformed `[]'
>>
>> error.
>> I forgot to mention and I had an alternative solution from the
>> beginning /stat[abc]?([ ;]|-)/
>> I'm just wondering the reason the original version failed.
>
> As I recall, if you're going to include a hyphen in a character
> class, it has to be the first character so that it isn't taken to
> indicate a range.
That's posix & perl regexps.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 15:31 ` hugo rivera
@ 2010-07-13 16:00 ` erik quanstrom
2010-07-13 18:38 ` Russ Cox
0 siblings, 1 reply; 20+ messages in thread
From: erik quanstrom @ 2010-07-13 16:00 UTC (permalink / raw)
To: 9fans
> I wasn't searching, but using it with acme's x command.
>
> > if you are doing a b3 search, you want
> >
> > :/stat[abc]?[ ;\-]/
> >
> > just the leading : is missing.
this works for me on a buffer of "stat-\n\n\n\n"
(where \ns are newlines):
Edit ,x/stat[abc]?[ ;\-]/p
> As I recall, if you're going to include a hyphen in a character
> class, it has to be the first character so that it isn't taken to
> indicate a range.
from regexp(6)
[...]
In s {as in [s-s]}, the metacharacters `-',
`]', an initial `^', and the regular expression delimiter
must be preceded by a `\'; other metacharacters have no spe-
cial meaning and may appear unescaped.
> maybe I'm using a buggy version of acme, because /stat[abc]?[- ;]/
> also fails with a "malformed" error. And according to the regexp(7)
> man page, you should be able to precede a '-' with a backslash.
no, the correct version is
/stat[abc]?[\- ;]/
- erik
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 16:00 ` erik quanstrom
@ 2010-07-13 18:38 ` Russ Cox
2010-07-13 18:46 ` blstuart
` (3 more replies)
0 siblings, 4 replies; 20+ messages in thread
From: Russ Cox @ 2010-07-13 18:38 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
I think you have found a real bug.
I created a new window containing
x x+ x- xy
and I executed Edit ,x/x[ +\-]/d
and sure enough it doesn't delete x-.
Russ
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 18:38 ` Russ Cox
@ 2010-07-13 18:46 ` blstuart
2010-07-14 7:47 ` hugo rivera
2010-07-13 18:47 ` erik quanstrom
` (2 subsequent siblings)
3 siblings, 1 reply; 20+ messages in thread
From: blstuart @ 2010-07-13 18:46 UTC (permalink / raw)
To: 9fans
> I think you have found a real bug.
>
> I created a new window containing
>
> x x+ x- xy
>
> and I executed Edit ,x/x[ +\-]/d
> and sure enough it doesn't delete x-.
Interesting. Is that in p9p acme? I just tried it in 9vx
and it did delete everything except the xy.
BLS
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 18:38 ` Russ Cox
2010-07-13 18:46 ` blstuart
@ 2010-07-13 18:47 ` erik quanstrom
2010-07-13 18:49 ` erik quanstrom
2010-07-13 18:57 ` erik quanstrom
3 siblings, 0 replies; 20+ messages in thread
From: erik quanstrom @ 2010-07-13 18:47 UTC (permalink / raw)
To: 9fans
On Tue Jul 13 14:40:02 EDT 2010, rsc@swtch.com wrote:
> I think you have found a real bug.
>
> I created a new window containing
>
> x x+ x- xy
>
> and I executed Edit ,x/x[ +\-]/d
> and sure enough it doesn't delete x-.
this really does work for me at coraid, but not at home.
the only difference i see is the fact that at coraid, 16-bit
runes are used, while i am using 32-bit runes.
/n/coraid//sys/src/cmd/acme/regx.c:487,493 - regx.c:487,493
exprp++; /* eat '-' */
if((c2 = nextrec()) == ']')
goto Error;
- classp[n+0] = 0xFFFF;
+ classp[n+0] = Runemax;
classp[n+1] = c1;
classp[n+2] = c2;
n += 3;
- erik
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 18:38 ` Russ Cox
2010-07-13 18:46 ` blstuart
2010-07-13 18:47 ` erik quanstrom
@ 2010-07-13 18:49 ` erik quanstrom
2010-07-13 18:57 ` erik quanstrom
3 siblings, 0 replies; 20+ messages in thread
From: erik quanstrom @ 2010-07-13 18:49 UTC (permalink / raw)
To: 9fans
the problem is that OPERATOR, and nextrec() now collide
with legit runes.
- erik
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 18:38 ` Russ Cox
` (2 preceding siblings ...)
2010-07-13 18:49 ` erik quanstrom
@ 2010-07-13 18:57 ` erik quanstrom
2010-07-14 18:11 ` Russ Cox
3 siblings, 1 reply; 20+ messages in thread
From: erik quanstrom @ 2010-07-13 18:57 UTC (permalink / raw)
To: 9fans
patch:
/n/dump/2010/0713/sys/src/cmd/acme/regx.c:20,26 - regx.c:20,26
typedef struct Inst Inst;
struct Inst
{
- uint type; /* < 0x10000 ==> literal, otherwise action */
+ uint type; /* < 0x1000000 ==> literal, otherwise action */
union {
int sid;
int subid;
/n/dump/2010/0713/sys/src/cmd/acme/regx.c:61,85 - regx.c:61,85
* 0x100xx are operators, value == precedence
* 0x200xx are tokens, i.e. operands for operators
*/
- #define OPERATOR 0x10000 /* Bitmask of all operators */
- #define START 0x10000 /* Start, used for marker on stack */
- #define RBRA 0x10001 /* Right bracket, ) */
- #define LBRA 0x10002 /* Left bracket, ( */
- #define OR 0x10003 /* Alternation, | */
- #define CAT 0x10004 /* Concatentation, implicit operator */
- #define STAR 0x10005 /* Closure, * */
- #define PLUS 0x10006 /* a+ == aa* */
- #define QUEST 0x10007 /* a? == a|nothing, i.e. 0 or 1 a's */
- #define ANY 0x20000 /* Any character but newline, . */
- #define NOP 0x20001 /* No operation, internal use only */
- #define BOL 0x20002 /* Beginning of line, ^ */
- #define EOL 0x20003 /* End of line, $ */
- #define CCLASS 0x20004 /* Character class, [] */
- #define NCCLASS 0x20005 /* Negated character class, [^] */
- #define END 0x20077 /* Terminate: match found */
+ #define OPERATOR 0x1000000 /* Bitmask of all operators */
+ #define START 0x1000000 /* Start, used for marker on stack */
+ #define RBRA 0x1000001 /* Right bracket, ) */
+ #define LBRA 0x1000002 /* Left bracket, ( */
+ #define OR 0x1000003 /* Alternation, | */
+ #define CAT 0x1000004 /* Concatentation, implicit operator */
+ #define STAR 0x1000005 /* Closure, * */
+ #define PLUS 0x1000006 /* a+ == aa* */
+ #define QUEST 0x1000007 /* a? == a|nothing, i.e. 0 or 1 a's */
+ #define ANY 0x2000000 /* Any character but newline, . */
+ #define NOP 0x2000001 /* No operation, internal use only */
+ #define BOL 0x2000002 /* Beginning of line, ^ */
+ #define EOL 0x2000003 /* End of line, $ */
+ #define CCLASS 0x2000004 /* Character class, [] */
+ #define NCCLASS 0x2000005 /* Negated character class, [^] */
+ #define END 0x2000077 /* Terminate: match found */
- #define ISATOR 0x10000
- #define ISAND 0x20000
+ #define ISATOR 0x1000000
+ #define ISAND 0x2000000
/*
* Parser Information
/n/dump/2010/0713/sys/src/cmd/acme/regx.c:452,458 - regx.c:452,458
exprp++;
return '\n';
}
- return *exprp++|0x10000;
+ return *exprp++|0x1000000;
}
return *exprp++;
}
/n/dump/2010/0713/sys/src/cmd/acme/regx.c:492,498 - regx.c:492,498
classp[n+2] = c2;
n += 3;
}else
- classp[n++] = c1;
+ classp[n++] = c1 & ~0x1000000;
}
classp[n] = 0;
if(nclass == Nclass){
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 18:46 ` blstuart
@ 2010-07-14 7:47 ` hugo rivera
0 siblings, 0 replies; 20+ messages in thread
From: hugo rivera @ 2010-07-14 7:47 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Yes, I'm using acme from p9p.
2010/7/13 <blstuart@bellsouth.net>:
>> I think you have found a real bug.
>>
>> I created a new window containing
>>
>> x x+ x- xy
>>
>> and I executed Edit ,x/x[ +\-]/d
>> and sure enough it doesn't delete x-.
>
> Interesting. Is that in p9p acme? I just tried it in 9vx
> and it did delete everything except the xy.
>
> BLS
>
>
>
--
Hugo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-13 18:57 ` erik quanstrom
@ 2010-07-14 18:11 ` Russ Cox
2010-07-15 8:15 ` hugo rivera
0 siblings, 1 reply; 20+ messages in thread
From: Russ Cox @ 2010-07-14 18:11 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
thanks for tracking this down.
fixed in p9p, with some extra names.
sam needs the same changes.
libregexp is okay.
http://code.swtch.com/plan9port/changeset/239be7f74189
russ
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [9fans] regexp doubt
2010-07-14 18:11 ` Russ Cox
@ 2010-07-15 8:15 ` hugo rivera
0 siblings, 0 replies; 20+ messages in thread
From: hugo rivera @ 2010-07-15 8:15 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Thanks to you, guys.
2010/7/14 Russ Cox <rsc@swtch.com>:
> thanks for tracking this down.
> fixed in p9p, with some extra names.
> sam needs the same changes.
> libregexp is okay.
>
> http://code.swtch.com/plan9port/changeset/239be7f74189
>
> russ
>
>
--
Hugo
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2010-07-15 8:15 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-13 14:56 [9fans] regexp doubt hugo rivera
2010-07-13 15:01 ` Vinu Rajashekhar
2010-07-13 15:11 ` hugo rivera
2010-07-13 15:15 ` Rodolfo (kix)
2010-07-13 15:31 ` hugo rivera
2010-07-13 15:37 ` blstuart
2010-07-13 15:46 ` hugo rivera
2010-07-13 15:50 ` Ethan Grammatikidis
2010-07-13 15:18 ` erik quanstrom
2010-07-13 15:31 ` hugo rivera
2010-07-13 16:00 ` erik quanstrom
2010-07-13 18:38 ` Russ Cox
2010-07-13 18:46 ` blstuart
2010-07-14 7:47 ` hugo rivera
2010-07-13 18:47 ` erik quanstrom
2010-07-13 18:49 ` erik quanstrom
2010-07-13 18:57 ` erik quanstrom
2010-07-14 18:11 ` Russ Cox
2010-07-15 8:15 ` hugo rivera
2010-07-13 15:48 ` yy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).