tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <bay...@generationjava.com>
Subject Re: Bay or Glen, String Replace tag broken
Date Fri, 07 Dec 2001 15:41:44 GMT
Doh :)

Looks like a good call. Thanks Ben.

Bay

On Fri, 7 Dec 2001, Neuman, Ben J. , AFIS-HQ/IRM wrote:

> Hi!
> The String tag replace is broken. It looks like you need to change the
> StringW class method:
>
> static public String replaceString(String text, String repl, String with,
> int n) {
>         int idx = 0;
>         while( (idx = text.indexOf(repl)) != -1) {
>             text = text.substring(0,idx) + with +
> text.substring(idx+repl.length() );
>             idx += with.length();    // jump beyond replacement
>             n--;
>             if(n == 0) {
>                 break;
>             }
>         }
>         return text;
>     }
>
> to:
>
> static public String replaceString(String text, String repl, String with,
> int n) {
>         int idx = 0;
>         while( (idx = text.indexOf(repl, idx)) != -1) {
>             text = text.substring(0,idx) + with +
> text.substring(idx+repl.length() );
>             idx += with.length();    // jump beyond replacement
>             n--;
>             if(n == 0) {
>                 break;
>             }
>         }
>         return text;
>     }
>
> If this is alleady done, please ignore. Just trying to help.
> Thanks,
> Ben
>
>
> --
> To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message