Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/bb|[^b]{2}/ how does it work? [closed]

Tags:

regex

Can someone please explain? I read this on a t-shirt:

enter image description here

It seems to be saying: "To be or not to be"

How? I do not seem to be finding 'e'? :p

How exactly does this regex techy/geeky?

like image 479
hari Avatar asked Jul 11 '11 18:07

hari


2 Answers

Assuming # for comments:

 /
  bb     # two b's
  |      #  or 
  [^     #  not
   b]{2} #  two b's
 /
like image 165
OscarRyz Avatar answered Nov 16 '22 09:11

OscarRyz


Unfortunately the correct description would be: "two b or not b and not b" or "two b and two not-b" (which doesn't really gets close to "to be or not to be").

/bb|[^b]{2}/ => /bb|[^b][^b]/

Of course "two b or not two b" matches anything when expressed in regular expression!

like image 43
Howard Avatar answered Nov 16 '22 09:11

Howard