Regular expressions should be renamed awesome expressions

by dotnetpete 3. May 2011 16:17

There is nothing regular about regexs. Awesome expressions doesn't roll of the tongue as nicely but it's what they are.

Some cool uses I have found:

  1. Swap variable assignment direction i.e. a=b => b=a.
  2. Generation of class property code from a list of column names.

Today I had an Excel sheet with two columns that I needed to import into a QL database. On each row the values were tab separated. I was able to use "\(.+\)\t\(.+\)" in my find expression and "insert into temp values(\1,'\2')" in my replace expression to do the job.

They are complex to master and get crazy very quickly - regex for validating email addresses - but they are well worth the effort.

Tags:

Add comment




biuquote
Loading