Skip to content

Instantly share code, notes, and snippets.

@smathy
Created August 6, 2010 21:21
Show Gist options
  • Save smathy/512029 to your computer and use it in GitHub Desktop.
Save smathy/512029 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl -l
# Sample string with positional captures...
# v1 v2 v3 v4 v5 v6
# 8078536407464790057000 GDL SLP Aug 04 2010 09:24AM SDR:MARIA TERESA RUIZ 0270842431
$_ = '8078536407464790057000 GDL SLP Aug 04 2010 09:24AM SDR:MARIA TERESA RUIZ 0270842431';
/
^
\s*
(\d+) # v1
\s+
([a-z]+) # v2
\s+
([a-z]+) # v3
\s+
([a-z]{3}\s+\d{2}\s+\d{4}\s+\d{2}:\d{2}[ap]m) # v4
\s+
(?:[a-z]+:)*
(.+) # v5
\t\s+
(\d+) # v6
\s*
$
/xi;
print " [$1] [$2] [$3] [$4] [$5] [$6] ";
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment