Regular expressions

Yesterday I had to create a webpage out of raw data so I remembered a few things about regular expressions to automate the process. The search and replace that did the trick was:

Search : *(.*?);
Replace: <a href="$1">$1</a>;

The example above is very simple and regular expressions that detect urls do exist but it was a quick fix for the task in hand.

Back then Textpad was the tool, now it’s Sublime. I liked better the dollar sign syntax of the Sublime implementation than the backslash Textpad syntax.

Maybe some other time I even dare to write:

import re

By looking around a beautiful regular expression that tests if a number is prime caught my attention.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s