> Building regexes programmatically requires escaping the inputs.
> For example, what if I want to trim any leading "bar" off a string and
I pass in
> "bar" as the start parameter and "rabid" as the str. Instead of
getting "rabid"
> back (because the prefix wasn't there to get removed) I instead get
back "id"
> because my start string was interpreted as a set of characters not a
literal
> string.
Agreed, sorry I just wrote that method into the comment box - it wasn't
meant to be a copy/paste solution :-)
> Building regexes programmatically requires escaping the inputs.
> For example, what if I want to trim any leading "bar" off a string and
I pass in
> "bar" as the start parameter and "rabid" as the str. Instead of
getting "rabid"
> back (because the prefix wasn't there to get removed) I instead get
back "id"
> because my start string was interpreted as a set of characters not a
literal
> string.
Agreed, sorry I just wrote that method into the comment box - it wasn't
meant to be a copy/paste solution :-)
https:/ /codereview. appspot. com/7327045/