Hi!
   I'm looking for a clean way of replacing all instances of a substring
with another. Sounds easy, right? Here's my desired functionality:

        MyReplaceAll("abc", "a", "z")    - zbc
        MyReplaceAll("abc", "a", "")     - bc
        MyReplaceAll("$1$2$3", "$", "b") - b1b2b3
        MyReplaceAll("abc", null, "foo") - abc
        MyReplaceAll("abc", "foo", null) - abc

String.replaceAll interprets the replacement values as regular
expressions, and chokes on $-signs. StringUtils.replace is **almost**
what I'm looking for, but (as per the javadocs):

        StringUtils.replace("abaa", "a", "", 1)    = "abaa"

I would expect replacing the String "a" with a blank string would result
in:

        StringUtils.replace("abaa", "a", "", 1)    = "baa" (max of one
replacement specified)

Am I just missing something here? Is there another function I should use
to "de-regex" my input strings, or have you guys found a better way of
doing this?

Thanks for your help in advance!

Michael Scovetta
Computer Associates
Senior Application Developer



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to