NOTICE:
This content is in the "archives" of a retired blog called Gadgetopia. It has been moved to this subdomain as it is no longer considered relevant to the site. It is being hosted here for a indeterminate period of time. Its existence at this URL is not guaranteed, and it may be removed at any time. If you would like to refer to this content in the future, you are encouraged to save it to your local file system.

Some content from Gadgetopia was moved to the technical blog on deanebarker.net

Bunny Regex

Originally published by "dbarker" on 2006-03-02 18:56:00Z

Introducing BunnyRegex: easy regular expressions, and mini-languages inside of PHP: Here’s a great little regex library for PHP that uses a dead-simple syntax that someone should have thought of way, way before this.

include(“BunnyRegex.php”); $pattern = new BunnyRegex();

$pattern->bol() // ^ ->digit() // \d ->exactly(4) // {4} ->string('/') // / ->digit() // \d ->exactly(2) // {2} ->string('/') // / ->digit() // \d ->exactly(2) // {2} ->eol(); // $

$pattern->match('2006/02/28’); // returns true $pattern->numberOfMatches('2006/02/28’); // returns 1

Comment by "Michel Fortin" on 2006-03-02 13:34:00Z
I still prefer the string version (^\d{4}/\d{2}/\d{2}$). This makes me think of the chaining of the < operator="" in="" the="" c++="" standard="" library="" stream="" classes.="" both="" are="" somewhat="" repurpusing="" the="" language="" syntax="" to="" mean="" other="" things.="" i'm="" not="" fond="" of=""> And I wouldn't want to have to write (or even worse: debug) big regular expressions as you can find in Markdown with a syntax like this. With so much verbosity it would be easy to get lost trying to understand the whole regex. But that was probably not the problem it was trying to solve. *[Note: why is the coment preview eating the two plus in C++? I had to write them as character entities.]*
Comment by "Deane" on 2006-03-03 16:07:00Z
But we're not all regex ninjas, Michel. What I've found with big regexes is that they're easy to understand while you're writing them, but when you go back to work with them later, they're a pain to get back up-to-speed on. I'm sure, however, that Markdown has regexes that are a bit above the standard, so it's not for everyone. >why is the coment preview eating the two plus in C++? I had to write them as character entities. It's your language, dude. You tell me.
Comment by "Michel Fortin" on 2006-03-03 07:34:00Z
I can't argue that current regular expression syntax is obscure and could be improved and made clearer. That is why big regexes in Markdown are all accompagnied by a comment explaining each part of them (list marker, blank line, link title ...); this way they are a lot easier to decipher. >
> >why is the coment preview eating the two plus in C++? I had to write them as character entities. >
> >It's your language, dude. You tell me. I'd bet it's because the Show Preview button issues a *GET* XMLHttpRequest where pluses are not being encoded as %2b as they should and are thus converted to spaces at the revceiving end prior entering Markdown.
Comment by "Deane" on 2006-03-03 10:09:00Z
>I'd bet it's because the Show Preview button issues a GET XMLHttpRequest where pluses are not being encoded as %2b as they should and are thus converted to spaces at the revceiving end prior entering Markdown. You just *had* to put it back on me didn't you? Way to pass the buck, man. I'll look at it.
Comment by "english childrens clothing" on 2006-09-02 13:00:00Z
Good site. Thank you. [http://ing.forect.be/](http://ing.forect.be/) hanging [http://beddi.facello.be/](http://beddi.facello.be/) childrens bedding and accessories [http://gu.hmeter.be/](http://gu.hmeter.be/) 1966 topps baseball [http://e-car.gainbel.be/](http://e-car.gainbel.be/) wishing well [http://ng.atavist.be/](http://ng.atavist.be/) animated congratulation cards [http://inde.unquati.be/](http://inde.unquati.be/) collectandsave [http://d-ki.gainbel.be/](http://d-ki.gainbel.be/) christmas card kit [http://ard.auntl.be/](http://ard.auntl.be/) topps [http://p-ca.giglous.be/](http://p-ca.giglous.be/) larry fritsch [http://nary.eurister.be/](http://nary.eurister.be/) cards stationary [http://ard-i.feignet.be/](http://ard-i.feignet.be/) thank you cards with photo insert [http://d-je.facello.be/](http://d-je.facello.be/) becket by jean [http://oto.auntl.be/](http://oto.auntl.be/) how many photos can a 256mb card hold [http://rd-ve.gtondily.be/](http://rd-ve.gtondily.be/) paperikoot [http://he.ematio.be/](http://he.ematio.be/) stitchery [http://worl.enolina.be/](http://worl.enolina.be/) pokémon [http://aptis.hmeter.be/](http://aptis.hmeter.be/) printable baptism card [http://ra.facello.be/](http://ra.facello.be/) discount photo insert christmas cards [http://d-c.uviabi.be/](http://d-c.uviabi.be/) calling card world [http://cloth.gainbel.be/](http://cloth.gainbel.be/) english childrens clothing