M
Mr P
Hey Perlistas...
I wanted to replace any and all multiple sequential EOLs with a single
one. This worked nicely:
(a) s/(\n)\n+/$1/g;
But thinking abot it some more. it occurred to me that these wouldn't
quite work
(b) s/(\n)\n/$1/g;
(c) s/\n(\n)/$1/g;
(d) s/\n\n/\n/g;
because even though they are greedy, they don't retrace. And
predictably they didn't work.
I've never really used assertions, at least not enough to be familiar
with them. I guess this would be a positive look-behind to force the
engine to retrace?
Can someone offer an example please where I can use something like s/
(\n)\n/$1/g; with an assertion to do what (a) does? It would be
instructional for me to see this example.
Thanks
I wanted to replace any and all multiple sequential EOLs with a single
one. This worked nicely:
(a) s/(\n)\n+/$1/g;
But thinking abot it some more. it occurred to me that these wouldn't
quite work
(b) s/(\n)\n/$1/g;
(c) s/\n(\n)/$1/g;
(d) s/\n\n/\n/g;
because even though they are greedy, they don't retrace. And
predictably they didn't work.
I've never really used assertions, at least not enough to be familiar
with them. I guess this would be a positive look-behind to force the
engine to retrace?
Can someone offer an example please where I can use something like s/
(\n)\n/$1/g; with an assertion to do what (a) does? It would be
instructional for me to see this example.
Thanks