Damien
Damien

Reputation: 4121

Java Regex and json

i have the following regex in place to validate the name field in my program and it works fine

^[a-zA-Z\\d\\s_.@\\-]*$

{"name":"jfhgjhf"}

I now want to add an embedded json element that I am passing in as part of my json (I am using Schema Form) I want my taskDetails element to accept the same charachters as name as well as the charachters {[/:="

I tried the following regex with no joy

^[a-zA-Z\\d\\s_.@\\-{\\]\\[}/\\\\/\\/ ':=]*$

{"name":"jfhgjhf","taskDetails":"{\"ids\":[{\"id\":\"jhgjghjghfjf\"}]}"}

Any help on this would be greatly appreciated

Thanks Damien

Upvotes: 0

Views: 87

Answers (1)

Roy Shmuli
Roy Shmuli

Reputation: 5019

This will do the work

^[a-zA-Z\d\s_.@{\\}\/ ':=",\[\]-]*$

- must be final char because it can recognize for example a-z

http://regexr.com/

Upvotes: 2

Related Questions