I've a text field on UI. It does not restrict user to enter any special char. But while storing it in DB I want anything to be removed except alphabets and numerics.
It can be done at the client (JavaScript) side or the server (Java) side (though I want to do it on server side).
I used
str.replaceAll("[^a-zA-Z0-9]", "");
to do the task, but it would give an error:
Invalid char sequence
when entered something like "24 \ 7". Is there any way to handle these kind of escape sequence or I should do it on client side(using javascript)? means remove all unwanted chars in js only?
"24 \ 7"is you string input and you want to convert this into"24 7". Am I correct?stris created than the replace. Can you show that code?