Re: [android-developers] Re: String.replaceAll with regular expression

2013-04-07 Thread Ralph Bergmann | the4thFloor.eu
Am 07.04.13 09:34, schrieb Lew:
> Ralph Bergmann wrote:
> Caused by: java.util.regex.PatternSyntaxException: Invalid value for
> match mode flags near index 4:
> (?w=[0-9]+)
> ^

I found it, the problem is the ? at the beginning. It is also a regex
metacharacter.
"([?]w=[0-9]+)" works :-)


Ralph

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Re: String.replaceAll with regular expression

2013-04-07 Thread Lew
Ralph Bergmann wrote:

> I want to replace parts of a string but get an error :-( 
>
> The code: 
>
> String reSiezedURL = "foo"; 
>
> reSiezedURL = reSiezedURL.replaceAll("(?w=[0-9]+)", 
>

"reSiezed"?
 

> String.format("?w=%d", this.reqWidth)); 
> reSiezedURL = reSiezedURL.replaceAll("(&w=[0-9]+)", 
> String.format("&w=%d", this.reqWidth)); 
> reSiezedURL = reSiezedURL.replaceAll("(?h=[0-9]+)", 
> String.format("?h=%d", this.reqHeight)); 
> reSiezedURL = reSiezedURL.replaceAll("(&h=[0-9]+)", 
> String.format("&h=%d", this.reqHeight)); 
>
> The error: 
>
> Caused by: java.util.regex.PatternSyntaxException: Invalid value for 
> match mode flags near index 4: 
> (?w=[0-9]+) 
> ^ 
> at java.util.regex.Pattern.compileImpl(Native Method) 
> java.util.regex.Pattern.compile(Pattern.java:407) 
> at java.util.regex.Pattern.(Pattern.java:390) 
> at java.util.regex.Pattern.compile(Pattern.java:381) 
> at java.lang.String.replaceAll(String.java:1774) 
>
> The question: 
>
> What is wrong with my regular expression? 


http://developer.android.com/reference/java/util/regex/Pattern.html

I see nothing there that indicates your expression is legal.

-- 
Lew
 

>  
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.