Link to home
Start Free TrialLog in
Avatar of Terry Woods
Terry WoodsFlag for New Zealand

asked on

Regular expression for "To be or not to be"... just for fun

I've seen a t-shirt design where the text on the front is:
/bb|[^b]{2}/

Open in new window

which is meant to be a witty version of "To be or not to be". Pretty clever...

However, I think the pattern:
/bb|(?!bb)/

Open in new window


probably is a more accurate translation of the phrase. Thoughts?

Are there any other witty regular expression patterns out there?

The only other one I remember seeing is something like: s/microsoft/linux/gi
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Well, the first pattern reads "2 bs or/alternate not b twice". Rearranging it's "2 b or not 2 b".

Your pattern reads "2 bs or/alternate not 2 bs ahead". Rearranging it's "2 b or not 2 b ahead". More of a sports line.

HTH,
Dan
This might get you angry looks from girls:
(?![0-57-9])\d[^\D0-8]\?

Open in new window

but again, if a girl can read that, chances are the invite was not for her...
Avatar of Terry Woods

ASKER

The first pattern I read as "2b's or 2 not-b's"...

Thanks, though I don't think I'd wear your suggestion on my chest! I suppose it could be modified to something like this with extra geeky meaning (wouldn't look so good in PHP... maybe a javascript version would look ok?):

$life['meaning'] = /(?![0-35-9])\d[^\D013-9]/

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial