Normalizing Strings using Regexes

Posted by RasputinJones on Stack Overflow See other posts from Stack Overflow or by RasputinJones
Published on 2010-05-25T15:58:40Z Indexed on 2010/05/25 16:01 UTC
Read the original article Hit count: 134

Filed under:
|

How do I match this string "1 & 2" from this string "Foo Bar 1 & 2"?

How do I match this string "1, 2 & 3" from this string "Foo Baz 1, 2 & 3"?

Trying to split out "Foo Bar" from the string using regexes while using the presence of "1 & 2" or "1, 2 & 3" as conditionals to normalize these strings into "Foo Bar 1" and "Foo Bar 2" or "Foo Baz 1", "Foo Baz 2" and "Foo Baz 3" respectively.

© Stack Overflow or respective owner

Related posts about regex

Related posts about normalization