6

There is a common Regex used to slugify urls ~[^\\pL\d]+~u but what does the\\pL in the first preg_replace() mean?

Here are some examples:

Community
  • 1
  • 1
Adrian
  • 103
  • 1
  • 6

2 Answers2

11

\\pL is a Unicode property shortcut. It can also be written as as\p{L} or \p{Letter}. It matches any kind of letter from any language.

Amal Murali
  • 70,371
  • 17
  • 120
  • 139
5

\\pL is a shorthand for \\p{L}

reference

In addition to the standard notation, \p{L}, Java, PHP, Perl, PCRE and the JGsoft engine allow you to use the shorthand \pL. The shorthand only works with single-letter Unicode properties. \pLl is not the equivalent of \p{Ll}. It is the equivalent of \p{L}l which matches Al or àl or any Unicode letter followed by a literal l.

Jabari
  • 4,869
  • 2
  • 24
  • 32
hsz
  • 136,835
  • 55
  • 236
  • 297