Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to substitute all the words before a certain word in the middle of a line?

by vkonovalov (Monk)
on Jul 12, 2000 at 09:36 UTC ( [id://22157]=note: print w/replies, xml ) Need Help??


in reply to How to substitute all the words before a certain word in the middle of a line?

s/\b\w+\s+nice\b/A nice/g;
or
$w = 'nice'; $r = 'A'; s/\b\w+(\s+$w)\b/$r$1/g;
should work

Replies are listed 'Best First'.
RE: Re: How to substitute all the words before a certain word in the middle of a line?
by le (Friar) on Jul 12, 2000 at 11:19 UTC
    The first one does not work, at least not here, when I supply the given sentence.
    You just replace the last word before 'nice' with 'A'.
      More careful reading will help in my case :)
      The word "all" was lost by me :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://22157]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-29 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found