fork download
  1. <?php
  2.  
  3. // com opção 'u' (Unicode), \w retorna 1 (match)
  4. // acentos (è e á)
  5. print(preg_match('/^\w+$/u', 'lumière'). "\n");
  6. print(preg_match('/^\w+$/u', 'á'). "\n");
  7. // caracteres japoneses
  8. print(preg_match('/^\w+$/u', '今日'). "\n");
  9.  
  10. // não usar \w, todos retornam 0 (não dá match), mesmo usando opção 'u'
  11. print(preg_match('/^[A-Za-z0-9_]+$/u', 'lumière'). "\n");
  12. print(preg_match('/^[A-Za-z0-9_]+$/u', 'á'). "\n");
  13. print(preg_match('/^[A-Za-z0-9_]+$/u', '今日'). "\n");
  14.  
  15.  
  16.  
Success #stdin #stdout 0.02s 23712KB
stdin
Standard input is empty
stdout
1
1
1
0
0
0