RegEx to prepend a default value to string IF NOT BLANK
A
Allison Bolduc
started a topic
over 5 years ago
Hello fellow RegExers,
Does anyone know of a useful regular expression that can prepend a default value to the beginning of an alpha-numeric string only IF NOT BLANK?
Example - If there is an actual value present in column X, then prepend "2016" to that value. If there isn't a value (blank) there, then do nothing but leave blank.
This works too, but his is better. First line: Replacement value: 2016$& value to match on ^(?=\s*\S).*$ Second line: replacement value: -BLANK- value to match on: ^\s*$
W
Wayne Pozzar
said
over 5 years ago
nice John!
+ = "one or more" so mine just says "one or more of any character". In this case I am assuming that we would count spaces as characters.
A
Allison Bolduc
said
over 5 years ago
Awesome!! It was for prepending before a team name, which could be open text and contain practically anything or be blank. Huge help, thanks to you both!!
Allison Bolduc