laziness, impatience, and hubris | |
PerlMonks |
Tri state string compare? (Solved! see update2)by BrowserUk (Patriarch) |
on Dec 13, 2015 at 18:22 UTC ( [id://1150172]=perlquestion: print w/replies, xml ) | Need Help?? |
BrowserUk has asked for the wisdom of the Perl Monks concerning the following question: I have two strings to compare.
I need to determine if string 2 contains As everywhere there is an A in string 1; and Bs wherever string 1 contains Bs. I don't care what string 2 contains where string 1 contains Cs. All I need is a boolean result whether string 2 'matches' string 1. (The above example is a 'match'.) If it helps, the choice of the 3 characters used is open to change. The strings can be quite long and there are lots of string 2s to be compared against each string 1; so I'd rather avoid a byte by byte (at the Perl level) comparison. I think it ought to be possible to get my boolean using some combination of byte-wise boolean string ops; but I haven't hit on which? Update: The above two samples match because:
Update2: SolutionSolved it with:
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
Back to
Seekers of Perl Wisdom
|
|