Replace String pattern in Java

Posted by Hirantha on Stack Overflow See other posts from Stack Overflow or by Hirantha
Published on 2013-10-29T09:14:44Z Indexed on 2013/10/29 9:54 UTC
Read the original article Hit count: 163

Filed under:
|

I have the following string

"value=\"\\d{4}((((0[1-9])|(1[0-2]))((0[1-9])|([12]\\d)|(3[01]))?)?|(\\-(((0[1-9])|(1[0-2]))(\\-((0[1-9])|([12]\\d)|(3[01])))?)?)?)d{4}"

There I want to replace all the occurrences of

"{" with NCHAR(0x7B)
"}" with NCHAR(0x7D). 

An the content in-between "{ }" should remain unchanged:

Ex: \\d{4} after replacing -> NCHAR(0x7B) 4 NCHAR(0x7D).

Is there a way to do this using Regular Expressions in Java?.

Anyway, this can be done processing the whole string using string operations.

© Stack Overflow or respective owner

Related posts about java

Related posts about regex