Flagrant Badassery

A JavaScript and regular expression centric blog



…That is the question. ThinkGeek is selling that on a t-shirt for the "regular expression junkie + lover of literature." Wearing that around would be a sure way to get me to notice you, especially if you have a nice rack or happen to be Angelina Jolie.

Note that the parentheses are unnecessary except in the case of Perl-folk wishing to avoid using the naughty $& variable for performance reasons. Also, the expression is buggy in that many alternatives to "bb" are not matched, so it would probably be better written as simply /bb|.*/s. For a JavaScript solution you could try var answer = /^bb$/.test(i);.

Alright, I'm done debugging the shirt now.

There Are 22 Responses So Far. »

  1. /bb|(?!bb).*/

  2. I find it funny that while you were debugging shirts I was busy debugging the pants off girls.

    And I don’t even know what that means.

  3. Yeah, well, I was worn out from debugging your mom’s back-end.

  4. That’s ok because I already checked all my code into your mom’s repository.

    And I expect to be pushing some more code tomorrow night.

  5. Also –

    I had an atomic grouping with your mom and some friends, but her lazy repetition was not impressing me. Then when I was done she became a bit of a possessive quantifier so I finished the job with $.

  6. Haha, it was a bit of a stretch. But I did come up with some more generalized geek talk ones:

    Last night I inserted my Dongle into your mom’s hub but I didn’t use my Trojan.

    I spent all morning servicing your mom’s asynchronous requests. On an unrelated note I heard some guy invoked the getPenis() method of your service and received a 404 status code – Not found.

    I think your mom’s cache is going to need some clearing because I just filled it.

  7. Your mom’s repository is so old that I don’t need to use version control.

    As for your regex dirty-talk, that’s just dreadful, but I’ve got nothing.

  8. ^^ That was just dreadful!

  9. That’s just friggin hillarious. Myself, if I gotta debug a chick (or her clothes), she ain’t worth it.

  10. debugging girls?? Methinks you need to de-louse her first… creepy πŸ˜‰

  11. /bb|.*/s and /(bb|[^b]{2})/ aren’t equivalent my friend =)

    Any single-character string is matched by yours but not the original. Also any two-character string containing only one b. In fact, yours will match anything including an empty string.

    It’s funny to see Azat came up with essentially the same answer I did =) Except one half of his alternation consumes while the other half doesn’t – which might be his intention, but it’s more likely you’d want both sides of the alternation to consume, or neither side to consume. That’s why I prefer /(?=bb)|(?!bb)/ (non-consuming) or /(?:(?=bb)|(?!bb))../.

    This last one can be reduced to /.{2}/, but that doesn’t read quite as well =)

  12. /bb|.*/s and /(bb|[^b]{2})/ arenÒ€ℒt equivalent my friend =)

    No kidding. πŸ™‚ That’s why I posted my implementation. Anything other than “bb” (including the empty string) is not “bb”. Therefore I read my regex as “two Bs or anything other than two Bs”, while I read the original as “two Bs or any two non-Bs, captured to group one”. I read your regexes here as “over-engineered, inefficient patterns that simply match any position or any two, non-line break characters.” πŸ˜› Mine can alternatively be read as “match either ‘bb’ or the first line of the subject string.”

  13. @ William “The Ownage” Bowen on 4 December 2007:

    one word. ROFL.

  14. Late to the party but I was searching your blog for the answer to something… and well while y’all can fight all you want about the regex I’m going to take exception to:

    var answer =

    it should be:

    var question =


  15. I’d buy this shirt if it said “String theory” on the back. ^_^

  16. @ Z on 12 December 2008:

    That’s 4 words bud.

  17. Invest $ 1284 and get $ 5325 every month: https://ss-d-ff.blogspot.co.il?es=28

  18. TOP # 1 EARNINGS ONLINE from $5949 per day: https://q1-earn-4000usd-per-week-162.blogspot.tw?h=20

  19. Good post. I learn something totally new and challenging on sites I stumbleupon on a daily basis. It’s always useful to read through content from other authors and use a little something from other web sites.

  20. Hello friends, nice paragraph and good arguments commented at this place, I am in fact
    enjoying by these.

  21. Thanks designed for sharing such a pleasant idea, post
    is pleasant, thats why i have read it completely

  22. Hello friends, nice paragraph and good arguments commented at this place, I am in fact
    enjoying by these.

Post a Response

If you are about to post code, please escape your HTML entities (&, >, <).