9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Sam: Is This a Bug?
@ 2024-10-03 21:37 kalterdev
  2024-10-03 21:55 ` umbraticus
  0 siblings, 1 reply; 3+ messages in thread
From: kalterdev @ 2024-10-03 21:37 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 754 bytes --]

Consider the following sample text:

foo
bar
baz
qux
quux

The purpose is to merge each pair of words, so that the text becomes:

foobar
bazqux
quux

The following command works fine:

x/.+\n.+/ x/\n/ d

But the following one does not:

x/.*\n.*/ x/\n/ d

It results in all \n being deleted.

I suppose it's because .* matches an empty string in this case. But
it really shouldn't. Sam's regular expressions are leftmost-longest.
And there's seemingly nothing that must stop both .* from extending.

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tabb641f45805a1fc-M3a459815536caaee8e5401c5
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 1669 bytes --]

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

* Re: [9fans] Sam: Is This a Bug?
  2024-10-03 21:37 [9fans] Sam: Is This a Bug? kalterdev
@ 2024-10-03 21:55 ` umbraticus
  2024-10-03 22:01   ` kalterdev
  0 siblings, 1 reply; 3+ messages in thread
From: umbraticus @ 2024-10-03 21:55 UTC (permalink / raw)
  To: 9fans

try this and it should make sense:

x/.+\n.*/ x/\n/ d

with .* to the left of the \n you get the following:

match foo\nbar and delete the \n
match \nbaz and delete the \n
match \nqux and delete the \n
match \nquux and delete the \n
match \n and delete it

umbraticus

------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tabb641f45805a1fc-M08971bc7fde7e72e022b08e3
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

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

* Re: [9fans] Sam: Is This a Bug?
  2024-10-03 21:55 ` umbraticus
@ 2024-10-03 22:01   ` kalterdev
  0 siblings, 0 replies; 3+ messages in thread
From: kalterdev @ 2024-10-03 22:01 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 249 bytes --]

Now I see. Thank you.
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tabb641f45805a1fc-M5d177572b05eceebe0335e0a
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

[-- Attachment #2: Type: text/html, Size: 737 bytes --]

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

end of thread, other threads:[~2024-10-03 22:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-03 21:37 [9fans] Sam: Is This a Bug? kalterdev
2024-10-03 21:55 ` umbraticus
2024-10-03 22:01   ` kalterdev

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