Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for 'wild' ascii charaters

Status
Not open for further replies.

lvennard

MIS
Apr 20, 2000
93
US
i have a log file that continues to get wierd ascii characters in it. The log file reader stops cold when it encounters them. Ive written a script that removes most of the problem areas but i am unable to remove ?binary? code from the log file since i cannot match it.

here is an example of a line i want removed
LN)ô§I@Maè³qÊX]RÌS<aúARï2SÚSf@\ZWSN²D>Za©'Á7ª ]ÌWXp@YèÁ2%ìd¢SMPPvF [&quot;M

the log is a web proxing log, so i imagine some sites are using binary encoding.

is there a regexp that will do this for me?
maybe something like &quot;> 126&quot; or something?

 
Is the binary data always on a separate line? If so, you might be able to use the following:

if ($Line =~ m/^\s*\w/) {
print &quot;ascii - $Line \n&quot;;
} else {
print &quot;binary - ignore \n&quot;;
}

Note that this handles a line w/ or w/o spaces starting with word character. Thus lines that start with a punctuation mark will be missed.

Another option is to using the &quot;ord&quot; function to get the ascii value of the first character.
 
unfortunatly no, it doesnt start on its own line.

&quot;date&quot;,&quot;time&quot;,&quot;user&quot;,&quot;website&quot;
&quot;date&quot;,&quot;time&quot;,&quot;user&quot;,&quot;website&quot;

in that format

the binary code is at the end of a link

here is any &quot;easy&quot; example.
&quot;[&quot;
 
You can use hex values in a regex, and you can make a character class with a range, so a regex like this
Code:
/[\x032-\x126]/
should match any &quot;normal&quot; character.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top