ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Abley <james.ab...@volantis.com>
Subject RE: regular expression
Date Mon, 07 Mar 2005 08:50:58 GMT
On Fri, 2005-03-04 at 18:20, Radha Sangal wrote:
> Here it is , I tested this code with the values in comments at end of
> statements and it was working but I think it doesn't work well with my
> actual string...
> 
> CharSequence inputStr = "codebase='formbuilderocx.cab#version=4,2,0,0'
> viewastext id='formbuilderocx' >"; // "a b c a b c";
>          String patternStr = "[0-9][0-9]+(,[0-9][0-9]){3}"; //"a";
>          String replacementStr = "3,7,0,5";
>  
>          // Compile regular expression
>          Pattern pattern = Pattern.compile(patternStr);
>  
>          // Replace all occurrences of pattern in input
>          Matcher matcher = pattern.matcher(inputStr);
>          String output = matcher.replaceAll(replacementStr);
>          System.out.println( "input" + inputStr);
>          System.out.println( "output" + output);
> 

http://www.weitz.de/regex-coach/

Useful tool for learning / debugging regular expressions.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message