When doing text manipulation, there are a number of regular expressions (RegEx) that I tend to use over and over again. Maybe you'll find them useful too.
Nifty,
/T
Problem | Find | Replace | Example: Before | Example: After |
Move text in brackets
from end of line to beginning of line
| ^(.*) (\[.*\])$ | \2: \1 | Yada yada [BC4]
Yada yada [POS123]
| [BC4]: Yada yada
[POS123]: Yada yada
|
Convert dates from
MM-DD-YYYY to YYYYMMDD
| ^(..)-(..)-(....) | \3\1\2 | 11-30-1998
01-23-2004
| 19981130
20040123
|
Clean phone numbers
(remove space, paren, dash, period)
| [ \-\.\(\)] | N/A | 999.888.7777
(555) 444-3333
| 9998887777
5554443333
|
Nifty,
/T
No comments:
Post a Comment