Still learning regexes

When data looks like this:


"965935","828WL8","MA",...
"1866TL","1866TL","ME",...

and you want to filter the first column, and print anything that is not numeric, the following sed directives will work, thanks to excellent answers on stackoverflow. The following example looks also for a blank second column.


{
/^"[0-9]+[^0-9",]+[0-9]*",/p
/^"[0-9]+",""/p
}

The part the confused me was including and , as part of the negated character class. So, I’m still learning regexes, and will be even more now that I’m doing more Perl development.

Advertisements

Leave a comment

Filed under Linux/Unix Utilities

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s