9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* RE: [9fans] regexp not greedy enough
@ 2004-05-12 17:06 Tiit Lankots
  2004-05-12 17:20 ` Russ Cox
  0 siblings, 1 reply; 11+ messages in thread
From: Tiit Lankots @ 2004-05-12 17:06 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

 
> Why? How do I get the whole region?

,x:/\*: .,/\*\//d

RTFM /sys/doc/sam/sam.ps
 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] regexp not greedy enough
  2004-05-12 17:06 [9fans] regexp not greedy enough Tiit Lankots
@ 2004-05-12 17:20 ` Russ Cox
  0 siblings, 0 replies; 11+ messages in thread
From: Russ Cox @ 2004-05-12 17:20 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> ,x:/\*: .,/\*\//d

/* printf("debugging\n"); /**/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] regexp not greedy enough
  2004-05-12 18:46       ` Scott Schwartz
@ 2004-05-12 19:21         ` rog
  0 siblings, 0 replies; 11+ messages in thread
From: rog @ 2004-05-12 19:21 UTC (permalink / raw)
  To: 9fans

> There are some scary comments in /sys/src/cmd/acme/elog.c that explain it.

they don't seem to explain why we get these messages
now when we didn't before feb 2003.

but... a little searching back through the dump (oh for a faster
worm!) shows that the only reason that the messages
are printed now (and weren't before) is that the check
was not made before, not that the problem wasn't happening.

so i guess the needling is worth it.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] regexp not greedy enough
  2004-05-12 18:42     ` rog
  2004-05-12 18:46       ` Scott Schwartz
@ 2004-05-12 18:53       ` Russ Cox
  1 sibling, 0 replies; 11+ messages in thread
From: Russ Cox @ 2004-05-12 18:53 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> messages anyway?

they can't happen.  something is wrong.
but i haven't tracked down what.

russ


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] regexp not greedy enough
  2004-05-12 18:28 ` boyd, rounin
@ 2004-05-12 18:46   ` rog
  0 siblings, 0 replies; 11+ messages in thread
From: rog @ 2004-05-12 18:46 UTC (permalink / raw)
  To: 9fans

> using 's' is a bad idea.  'x' is much more powerful and more appropriate but
> takes a bit of a quantum leap to get to grips with it.

'x' is not always sufficient. 's' is sometimes necessary.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] regexp not greedy enough
  2004-05-12 18:42     ` rog
@ 2004-05-12 18:46       ` Scott Schwartz
  2004-05-12 19:21         ` rog
  2004-05-12 18:53       ` Russ Cox
  1 sibling, 1 reply; 11+ messages in thread
From: Scott Schwartz @ 2004-05-12 18:46 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

| BTW what is it with those:
| 	elogapply: can't happen 49 49 25
| messages anyway?

There are some scary comments in acme/elog.c that explain it.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] regexp not greedy enough
  2004-05-12 17:14   ` Russ Cox
@ 2004-05-12 18:42     ` rog
  2004-05-12 18:46       ` Scott Schwartz
  2004-05-12 18:53       ` Russ Cox
  0 siblings, 2 replies; 11+ messages in thread
From: rog @ 2004-05-12 18:42 UTC (permalink / raw)
  To: 9fans

> ,x;/\*([^*]|\*[^/]|\n)*\*/;d

,x;/\*([^*]|\*[^/]|\*?\n)*\*/;d

does marginally better.

BTW what is it with those:

	elogapply: can't happen 49 49 25

messages anyway?



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] regexp not greedy enough
  2004-05-12 13:22 Matthias Teege
  2004-05-12 13:57 ` rog
@ 2004-05-12 18:28 ` boyd, rounin
  2004-05-12 18:46   ` rog
  1 sibling, 1 reply; 11+ messages in thread
From: boyd, rounin @ 2004-05-12 18:28 UTC (permalink / raw)
  To: matthias, Fans of the OS Plan 9 from Bell Labs

> But the regexp stops at the first '\n'.
>
> Why? How do I get the whole region?

usually this means that you need to explicitly stick a \n into the char
class or () expression.

using 's' is a bad idea.  'x' is much more powerful and more appropriate but
takes a bit of a quantum leap to get to grips with it.

did some linux driver hacking with sam this afternoon.  that kernel is
awful, but i think i have tamed it.  sam, on the other hand, is a charm.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] regexp not greedy enough
  2004-05-12 13:57 ` rog
@ 2004-05-12 17:14   ` Russ Cox
  2004-05-12 18:42     ` rog
  0 siblings, 1 reply; 11+ messages in thread
From: Russ Cox @ 2004-05-12 17:14 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

,x;/\*([^*]|\*[^/]|\n)*\*/;d


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] regexp not greedy enough
  2004-05-12 13:22 Matthias Teege
@ 2004-05-12 13:57 ` rog
  2004-05-12 17:14   ` Russ Cox
  2004-05-12 18:28 ` boyd, rounin
  1 sibling, 1 reply; 11+ messages in thread
From: rog @ 2004-05-12 13:57 UTC (permalink / raw)
  To: 9fans

> Why? How do I get the whole region?

nothing matches a newline except a newline itself.
so instead of:

	\/\*[^\/]*

i think you might want:

	\/\*([^\/]|\n)*

(BTW, it is possible to write a regexp to properly
match C-style comments, but it's quite involved.
minimal matching would make it quite easy, but i guess
there are good reasons not to implement it)



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [9fans] regexp not greedy enough
@ 2004-05-12 13:22 Matthias Teege
  2004-05-12 13:57 ` rog
  2004-05-12 18:28 ` boyd, rounin
  0 siblings, 2 replies; 11+ messages in thread
From: Matthias Teege @ 2004-05-12 13:22 UTC (permalink / raw)
  To: 9fans

as you know trying to use sam for editing. ;-) I have another
problem with a regexp. I comment out some text with s:(.|\n)*:/*\n&\n*/:
This works but now I try to delete all comments. First I try
to select the region with /\/\*[^\/]*. But the regexp stops at
the first '\n'.

Why? How do I get the whole region?
Matthias


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-05-12 19:21 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-12 17:06 [9fans] regexp not greedy enough Tiit Lankots
2004-05-12 17:20 ` Russ Cox
  -- strict thread matches above, loose matches on Subject: below --
2004-05-12 13:22 Matthias Teege
2004-05-12 13:57 ` rog
2004-05-12 17:14   ` Russ Cox
2004-05-12 18:42     ` rog
2004-05-12 18:46       ` Scott Schwartz
2004-05-12 19:21         ` rog
2004-05-12 18:53       ` Russ Cox
2004-05-12 18:28 ` boyd, rounin
2004-05-12 18:46   ` rog

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).