tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Neuman, Ben J. , AFIS-HQ/IRM" <bjnue...@hq.afis.osd.mil>
Subject Bay or Glen, String Replace tag broken
Date Fri, 07 Dec 2001 15:43:01 GMT
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>


Mime
View raw message