Q:

Regex for Rest Design

I want to implement a validation for java back end side.In java, I want that all characters are allowed except / # + % ?(5 characters).I think these characters may damage my rest structure.
I implement this pattern "^[^#%/+?]+$".But It is not working.Do you have any idea about pattern.
    if(data.getName.matches("^[^#%/+?]+$""){
 return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("data","error","new data is not proper")).body(null)

}
It return created status when i send /pen or pencil% like that.

A:

To match any of those characters, you could do something like:
if (s.matches(".*[#%\\/+?].*"))

See online demo here

