Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: How to replace on a smooth way?

by bestsiteeditor (Initiate)
on Apr 19, 2012 at 14:18 UTC ( [id://965974]=note: print w/replies, xml ) Need Help??


in reply to Re: How to replace on a smooth way?
in thread How to replace on a smooth way?

Thank you so much, but here comes the tricky part: I have to match "§" and in the replacement to use "& # 0167;" otherwise - either does not match for "& # 0167;", or replacing with "§" in it - brings strange prints

Replies are listed 'Best First'.
Re^3: How to replace on a smooth way?
by MidLifeXis (Monsignor) on Apr 19, 2012 at 14:31 UTC

    The stuff within the parens is a capture - if you move the § outside of the capturing parenthesis, and then add your required entity to the replacement text, it should do what you need.

    So, if you have a replacement s/(A\S+)/[$1]/ and want to replace A with something else, you would use s/A(\S+)/[B$1]/ instead, replacing A and B as necessary.

    A read of perlre, perlrequick, and perlretut may be helpful. I also wonder if HTML::Entities may be a more appropriate solution to the second requirement.

    --MidLifeXis

Re^3: How to replace on a smooth way?
by roboticus (Chancellor) on Apr 19, 2012 at 14:33 UTC

    bestsiteeditor:

    That sounds like you may have an encoding problem, then.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-23 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found