Closed Thread Icon

Topic awaiting preservation: Perl REGEX Hex character (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12824" title="Pages that link to Topic awaiting preservation: Perl REGEX Hex character (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Perl REGEX Hex character <span class="small">(Page 1 of 1)</span>\

 
Boudga
Maniac (V) Mad Scientist

From: Jacks raging bile duct....
Insane since: Mar 2000

posted posted 07-18-2003 18:42

I would like to search for a hex charater "A0" and remove it from my text file...is this possible with Perl. I would like to learn how to do it so please post examples or URLs that show how to perform this substitution.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 07-18-2003 19:37

sure you can search for hex like so

$test =~ s/\xA0//g;


a breakdown would be

s <-- substitute
/ <-- delimeter
\ <-- unescape
x <-- this is a hex value
/ <-- delimeter
/ <-- delimeter
g <-- look globally


or the decimal way (I think this is it)

$test =~ s/\160//g





.:[ Never resist a perfect moment ]:.

Boudga
Maniac (V) Mad Scientist

From: Jacks raging bile duct....
Insane since: Mar 2000

posted posted 08-07-2003 17:53

great thanks that helps...epanding on that though what if you need to search for hex codes '0D 0A' together? Right now I am removing these as \n at the beginning of my script then adding them in later in the script to fix formatting. If I could remove these without having to strip all the \n at the beginning of the script I'd be a lot happier.



hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana, USA
Insane since: Aug 2000

posted posted 08-09-2003 07:31

I assume that this relates to your other thread about finding tags in an HTML file.

The best way to do this is

code:
if  (not open(INPUT, "< file.html"))
{ print ("Can't open 'file.html'\n"); }
else
{
@input = <INPUT>; # This line reads the entire file into @input
close(INPUT);
chomp(@input); # This line removes the \n's from each line

foreach $line (@input)
{
# process each line
}
}






-- not necessarily stoned... just beautiful.

« BackwardsOnwards »

Show Forum Drop Down Menu