regex - Return first substring till It Matches in PHP -


i stuck this

i have string let say

$name = 'asdf_aadf01_2*f854?# sadf'; 

and need

'asdf_aadf01_2' in return means alpha numeric underscore until non alphanumeric , _ character found

use:

preg_match('/\w*/', $name, $match); 

$match[0] contain you're looking for.

\w matches alphanumeric or underscore character. * quantifier means match 0 or more of preceding element.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -