简体   繁体   中英

php regular expression to match first word between space and point

I have a string. there I need get a one word. this word is between space and point. for example

' 'word.

if it find many same pattern words, I need only first word.

As far as i understand, you could try :

/\s(\w+)\./

preg_match('/\s(\w+)\./', 'abc. def. ghi.', $m);
echo $m[1],"\n";

output:

def

您也可以使用T-Regx

echo pattern(' \w+\.')->match($yourString)->first();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM