good evening,
i need to check if the input match my regex or not
i use this pattern '@^[a-zA-Z\@]{3,30}$@is'
<?php
if( preg_match('@^[a-zA-Z\@]{3,30}$@is', 'input@input') ){ echo 'matched'; }else{ echo 'no match'; }
?>
if i removed the @ char the regex still return TRUE
<?php
if( preg_match('@^[a-zA-Z\@]{3,30}$@is', 'inputinput') ){ echo 'matched'; }else{ echo 'no match'; }
?>
i need to edit the regex so it should contain the @ char
You can use a look-ahead assertion to assert that:
Here the look-ahead assertion
(?=[^@]*@)ensures that there is at least one@.