php - Regexp to check for consecutive spaces -


I am beating my head in the table trying to write expressions that filter the strings only There are Swedish characters, hyphens and single whitespace - that is, it's not in two lines, I want it to be preg_match ('/ ^ [a-zà ?? a ?? a ?? a-zÃÆ'à ¤ â € œÃƒÆ'à ¢ â,¬Å¡Ãƒâ € šÃ, € SA, a · ssss ¶¶ ¶) + \ s {1} $ / ', $ B) and I think I have tried one hundred different models, but There is not working. How do I complete it?

Often, the best way to solve this kind of problem is to make it two < / Strong> Different Regular Expression Checks

  • Check that the string contains only letters that you want (and whitespace)
  • If the first check is passed, check that there are no two or more consecutive spaces Try

    Try:

      if (preg_match ('/ ^ [a-zà ?? a ?? a ?? a-zà ¥ ø ¤ ö- \ s] $ / ', $ b) & amp;; preg_match (' / \ s \ s + / ', $ b)) {/ ...}    

Comments