php - regular expression, match all text within two characters -


i need ask because takes me time go on again , again every time needed, how match this:

tom yorke(55555) 

when given this:

cn=tom yorke(55555),ou=admins,ou=london,ou=users,dc=domain,dc=london,dc=local 

using php preg_match()

only want first occurence of text within = , ,

try this. $result hold match, or null if there's not match

$data = "...";//original string $pattern = '/=([^,]+)/'; $matches = []; preg_match($pattern, $data, $matches); $result = count($matches)? $matches[1]: null; // tom yorke(55555) 

live demo


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -