I need to write regular expression that will match any sequence of predefined chars, ie in string “Hello,, world, xaxxa” will find double comma and x, but not the single occurencies. Hope this is not duplicate question but I could not find any answer… Thanks for help
I need to write regular expression that will match any sequence of predefined chars,
Share
Do you mean something like
See it here on Regexr
(.)matches any character and store it in a backreference (because of the brackets around). With the\1you access this backreference.So this will match any sequence of the same character.
If you have a defined set of characters, use a character class
See it here on Regexr
you can add any character to the class inside the square brackets.