in reply to Using Look-ahead and Look-behind
Returning to this example below…
s/(?<=look)(?=ahead)/-/g;…assume “look” and “ahead” are on separate lines one below the other. Then the line becomes this…
s/(?<=look)\n(?=ahead)/-/g;Is there some restriction, as the two words do not get joined with a dash? (At least for me)
Plus, there is no error message; the command just doesn’t work. My one-liner is below. I’ve ensured my apostrophe’s are correct after I copy/paste; plus, I’ve key-stroked every character, and tried numerous variations, etc., etc. Using Mac OS Sequoia 15.0 and perl 5.34.
perl -i -pe ’s/(?<=look)\n(?=ahead)/-/g;’ myfile.txt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using Look-ahead and Look-behind
by Corion (Patriarch) on Nov 28, 2024 at 06:18 UTC | |
by akiemr19 (Initiate) on Nov 28, 2024 at 13:24 UTC | |
by hippo (Archbishop) on Nov 28, 2024 at 14:06 UTC |