tags:

views:

54

answers:

4

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

preg_match ('/^[A-Z \'.-]{2,20}$/i')
+3  A: 

/ denotes the end of the pattern. The i is a modifier that makes the pattern case-insensitive, and the $ anchor matches the end of the string.

Jonathan Sampson
+3  A: 

the $ is an anchor -- it means the end of the string should be there. the / is the end delimiter for the regular expression. The i means that the regular expressions should be case-insensitive (notice that [A-Z \'.-] only matches A-Z -- the i means it doesn't have to look for a-z as well).

Carson Myers
+3  A: 

Dollar sign is a common regex symbol meaning "end of line".

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

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

Anthony
+1  A: 

$ Matches at the end of the string the regex pattern is applied to. Matches a position rather than a character

/ is the ending delimiter of the regex pattern in PHP

i represents case insensitive regular expression search

celalo