Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: character replace

by Corion (Patriarch)
on Jun 02, 2009 at 12:25 UTC ( #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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2023-12-03 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (20 votes). Check out past polls.

    Notices?