Regular expression selects, instead of the letters listed, all in a row



  • He wrote a regular expression for php. if( preg_match("/[Кк]ра[юй]/",$name));I wanted to make sure it missed the lines "Kray," "Kray," "krain," and "krain," but as a result, it somehow misses all the words that begin on the edge or on the Cra, which has a four-letter letter. I mean, the crab's missing. Please tell me why the last condition is. [юй]It doesn't work the way it takes to pass words not only with yu and yu, but with other letters?



  • Apparently, you work with me. utf8♪ For corrective work with a young person for regular expressions in the PHP, a modifier should be indicated u (grunts) Uu)

    melkij@melkij:~$ php -r 'var_dump(preg_match("/[Кк]ра[юй]/","краб"));'
    int(1)
    melkij@melkij:~$ php -r 'var_dump(preg_match("/[Кк]ра[юй]/u","краб"));'
    int(0)
    melkij@melkij:~$ php -r 'var_dump(preg_match("/[Кк]ра[юй]/u","край"));'
    int(1)
    

    Without this retrofit, the symbolic mask considers the 2-Bay codes of Cyrillians as two different symbols and will therefore not work normally.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2