The value of `$ / i` in regular expressions

What does $/i mean in the following php code?

 preg_match ('/^[AZ \'.-]{2,20}$/i') 
+4
source share
5 answers

/ denotes the end of the picture. i is a modifier , which makes the pattern case insensitive, and $ anchor matches the end of the line.

+4
source

$ is an anchor - this means that the end of the line should be there. / is the trailing delimiter for the regular expression. i means that regular expressions must be case insensitive (note that [AZ \'.-] matches only AZ - i means that it also does not need to look for az).

+3
source

The dollar sign is a common regular expression symbol meaning "end of line".

The slash at the end is the end of the expression itself.

Any letters after this slash are options that you can turn on or off, called modifiers. In case of i this means case insensitive.

+3
source

$ Matches at the end of the line to which the regular expression pattern is applied. Matches a position, not a character

/ is the final regexp delimiter in PHP

i represents the case of insensitive regular expression searches

+1
source

You can also use this to better understand things and can also be used for testing / practice.

http://gskinner.com/RegExr/

0
source

Source: https://habr.com/ru/post/1304430/


All Articles