Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Regex to replace a particular part of content

by GrandFather (Saint)
on Jun 23, 2006 at 18:10 UTC ( [id://557280]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Regex to replace a particular part of content
in thread Regex to replace a particular part of content

Now do it when you don't know what the text is up front and the text varies from line to line.

With this version you might as well just have used a print statement containing the litteral output. I'm sure in OP's real problem the text is not as shown. A better sample may have comprised words like "foo bar baz" and been much shorter, but there were enough lines there that you should probably have been able to read between them. :).


DWIM is Perl's answer to Gödel
  • Comment on Re^3: Regex to replace a particular part of content

Replies are listed 'Best First'.
Re^4: Regex to replace a particular part of content
by johngg (Canon) on Jun 23, 2006 at 18:57 UTC
    If it was a real world problem with real HTML/XML/whatever you would recommend some sort of parser rather than regular expressions. However, the OP asked for a regular expression (misguidedly) to modify a piece of unrealistic text (I can read between the lines as well as the next man, who's ever seen real world mark-up like that?:-). I've had some fun and learnt a few things trying to see if it could be done that way so I'm happy.

    Cheers,

    JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2024-04-26 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found