| Author |
validation Special character using Regular Expressions
|
skumar nand
Greenhorn
Joined: Dec 18, 2008
Posts: 21
|
|
Hi All,
we are try to Special character using Regular Expressions but \ (backslash) not validating using below code
please help us to validate Special character including \ (backslash) .
Thanks in advance.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16680
|
|
The backslash has special meaning to a regex AND to a java string. So, if you want the regex to not treat the backslash as special, and you want to use a string literal, then you need to escape twice.... giving you four backslashes.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
skumar nand
Greenhorn
Joined: Dec 18, 2008
Posts: 21
|
|
can you update the below Regular Expressions
Pattern pattern = Pattern.compile("[/,:<>!~@#$%^&()+=?()\"|!\\[#$-]");
|
 |
skumar nand
Greenhorn
Joined: Dec 18, 2008
Posts: 21
|
|
Hi Henry,
Am not understand what ever you say.
can you provide me a example or change my Expressions according you.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19214
|
|
Henry Wong wrote:giving you four backslashes.
Henry already gave you the answer.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: validation Special character using Regular Expressions
|
|
|