When I look up regular expressions for various purposes, I see people using delimiters like /, #, !, and ~. Do these do anything different, or do they have the same effect?
When I look up regular expressions for various purposes, I see people using delimiters
Share
They don’t do anything different, they delimit the regular expression (in languages where it is needed).
The difference is: the behaviour of that character inside the regex does change. The regex delimiter becomes an additional special character and needs to be escaped (==> choose a delimiter that you don’t need within the regex!).
Side note: In php you can even use a regex special character like
+or|as regex delimiter, but this works only when you don’t need that character inside the regex (NOT recommended). related answer