Let’s Regex

Halt, wary reader.

There be dragons and serpentine geeks prowling about today’s post. Leave now, or tread carefully. You have been warned.

——————–

I got my furry paws on one particular book today: Mastering Regular Expressions.

(This time, it’s for good. Oh, and while I was at it, I managed to pick up the Pocket Reference as well.)

I’ve been dying to get the book, having intended its purchase since a while ago. (But my wallet, and its thinness thereof, would not agree with my intentions, which is why I’ve had to put off the purchase until… well, just now.)

So standing before you today is a very happy man.

Why I Love Scientology Regular Expressions

I’m a recent proselyte to the regular expressions cult, really. At some point in the past year, after being fortunate enough to witness a miracle involving regex functions, I had then chosen to embrace the powers it offered me.

And we move to the present.

These days, most of the stuff I deal with require that I parse through oceans of raw text for duplicate strings, broken tags and/or repetitive string patterns. I’d often be very willing to cut the ordeal short by some automated means; after all, why would anyone want to deprive himself of precious living time? (Unless, of course, he were the kind to derive sadomasochistic pleasure from poring through endless lines of dirty strings, and you of all people would know that such a person could never be me. *Ahem.*)

And here is where regex functions come in. Them being the immensely useful creatures that they are, one would need only a single line of an elegantly pieced code, and that by itself would be enough to strip and sweep away all of the dirt, thus removing any need for endless hours of pointless rote cleaning.

Something like:

[^"\\\r\n]*(?:\\.[^"\\\r\n]*)*

Suffice to say that ever since I discovered regular expressions, one constant thought would always haunt my newly enlightened self whilst I go about any job.

And that thought, is this:

“Baby, where have you been all my life?”

So obviously, a coding bible of some sort, in printed form, like the one I acquired today, would make a lovely addition to the arsenal.

We now march onwards, in search of the Holy Grail (of Regex Functions).

——–

Speaking of which, I intend to write a tutorial on how I’ve used regex functions (combined with a number of other search-replace methods) to learn Japanese. So if you’re reading this, Khatzumoto-sensei, look forward to a hefty entry on that soon, yeah.



"

These days, most of the stuff I deal with require that I parse through oceans of raw text for duplicate strings, broken tags and/or repetitive string patterns. I’d often be very willing to cut the ordeal short by some automated means; after all, why would anyone want to deprive himself of precious living time?

"
Date: March 12th, 2008

Comments:

1. If you wish to comment, please write something that surpasses your very thoughtful "LOL". If that makes it too difficult for you to properly comment, don't.
2. I will reply in kind. If you're nice, polite and civil when commenting, I will reply in a similar manner. But if you're immature, (including but not limited to) stupid or hasty, I will delete any or all of your comments as soon as I get to them.
3. I don't delete comments unless they are clearly derogatory or off-topic. Feel free to share your thoughts.
4. This site employs spam protection, in the form of Akismet. Don't post anything that reeks of spam; otherwise, your comment won't see the light of day, and I probably won't know it existed either.