Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: How to use regular expression for this?

by graff (Chancellor)
on Aug 13, 2005 at 00:13 UTC ( [id://483468]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to use regular expression for this?
in thread How to use regular expression for this?

To elaborate on QM's solution explanation of AReed's solution, the "^" (exclusive-OR) operator, applied to two strings, will treat them as bit vectors, and return a string whose characters each represent 8 bits, in proper order, from the XOR result.

If the two strings have the same character at the same offset, the XOR result will be zero (null byte); the "tr/\0/ /" operation will not only convert the nulls to spaces, but will also return the number of nulls found and converted.

It's okay if the two strings are not the same length, because the shorter one will be padded with nulls as needed (and any value XOR 0 gives back that same value).

  • Comment on Re^3: How to use regular expression for this?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-12-09 23:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (55 votes). Check out past polls.