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

Re: character replace

by Corion (Patriarch)
on Jun 02, 2009 at 12:25 UTC ( [id://767571]=note: print w/replies, xml ) Need Help??

in reply to character replace

First you will need to define what the difference is between "the character '&'" and "the entities". Then you will need to write a regular expression that replaces "the character '&'" but not "the entities".

Of you're talking about HTML, consider the following cases:

Meier &Cie Muller & Co Dowe, Cheatham &Howe, Attorneys Wallpapers&Paint;

Replies are listed 'Best First'.
Re^2: character replace
by sandy1028 (Sexton) on Jun 02, 2009 at 12:28 UTC
    All the entities are in the text file. If the & exists in a file it should not be replaced, it only & is there then it has to be replaced with &

      That's great. So now you can start writing your code.

      In case you haven't noticed so far, Perlmonks is not a code writing service. You are expected to write your code yourself. We will help you with specific problems you have in your code but we will not write your programs for you.

        #!/usr/bin/perl open FH,'ent.txt'; @data=<FH>; $text='&bush&amp;'; foreach $dat(@data){ $text =~ s/&/&amp;/g; print $text; }
        ent.txt file contains all the entities. This substitutes all the & with &

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-23 15:07 GMT
Find Nodes?
    Voting Booth?

    No recent polls found