PHP Regex to allow special characters but no any space -


I have the following regs so that alphanumeric characters and the following special characters are allowed

  / () -   

is a regular expression

  / [^ a-za-z0-9 - () - /] /   

complete method

  public function valid number ($ number) {$ return = true; $ Matches = null; If ((preg_match ('/ [^ a-za-z0-9 - / () -] /', $ number, $ match) gt; 0) {$ return = false; } Return $ return; }   

The above method woks are fine, but if the number is replaced then TRUE also comes back. When I remove '/' from regx, then if the number is 'space' then it gets wrong.

It seems that there is some problem in 'Regex'.

Please give some advice to allow the letters of letters and the special characters above. Regex / () - << / p>

,
  ^ [A-Za-z0- 9 () \ / -] + $   

^ Inside (on top) Chocker class does not make sense. So your Részek character does not give any letters of the people described in the class. Even better to avoid / inside the character class and always consider entering - at the beginning or end of the character class. To allow more letters of one ore described in four classes, you must add + after the character range.

Explanation: The beginning of the string [A-Za-z0-9 () \ / -] + Any character: 'A' to 'Z', '$ 9', '(', '' ''), '' / 'before', and 'before' an optional \ n before 'a' and 'j', '0' before the string

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -