Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Question regarding a regex

by BillKSmith (Monsignor)
on Jul 23, 2021 at 02:31 UTC ( [id://11135332]=note: print w/replies, xml ) Need Help??


in reply to Question regarding a regex

Depending on your definition of 'text file', this test could give a false negative if the file contained any non-ASCII 'text'. It could give a false positive if every byte of a 'binary' file happened to contain the code of an ASCII character. (Can you tolerate an extremely rare error?)
Bill

Replies are listed 'Best First'.
Re^2: Question regarding a regex
by afoken (Chancellor) on Jul 23, 2021 at 08:09 UTC
    It could give a false positive if every byte of a 'binary' file happened to contain the code of an ASCII character. (Can you tolerate an extremely rare error?)

    I know only one binary file that intentionally contains only ASCII characters: The EICAR test file. Here it is, in its full glory:

    X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*

    It is a DOS executable that just prints the embedded text "EICAR-STANDARD-ANTIVIRUS-TEST-FILE!" and then exits.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Clever. I was thinking of a binary data file (Perhaps a sequence of readings from a 7-bit A/D converter).
      Bill

      impressive! and another form of golf is born.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-18 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found