PHP regex delimiter, what’s the point?

The reason for the delimiter is to put flags after the pattern. Arguably flags could be passed as a separate parameter (Java can do it this way) but that’s the way Perl did it originally (and sed/awk/vi before it) so that’s how it’s done now.

Don’t use forward slashes: they’re too common. Personally I nearly always use the ! character. I’m hardly ever looking for that.

Leave a Comment