I was wondering what is the best way to include backslash and other special characters in a group?
example:
"message":"\"rock on\" \\,,/,[-_-]";
help me on my regex
[a-zA-Z0-9 \\-~!@#$%^*()_+{}:|?`;',\\./\\[\\]]+
I was wondering what is the best way to include backslash and other special characters in a group?
example:
"message":"\"rock on\" \\,,/,[-_-]";
help me on my regex
[a-zA-Z0-9 \\-~!@#$%^*()_+{}:|?`;',\\./\\[\\]]+
Just escape those that need to be escaped and add those, that don't need to:
[a-zA-Z0-9 \\\-~!@#$%^*()_+{}:|"?`;',./[\]]+
To elaborate a bit:
You only need to escape \, ] and - inside a character group.
Using C#, it would look like this:
Regex rx = new Regex(@"[a-zA-Z0-9 \\\-~!@#$%^*()_+{}:|""?`;',./[\]]+");
] and not [.