开发者

Regular Expression: Match word and save anything else until space

开发者 https://www.devze.com 2023-04-13 05:27 出处:网络
I am trying to regex for words matching @food__ or #food__ in a string, so that I always match @food or #food and any other letters succeeding until a space. This i开发者_Python百科s giving me errors:

I am trying to regex for words matching @food__ or #food__ in a string, so that I always match @food or #food and any other letters succeeding until a space. This i开发者_Python百科s giving me errors:

preg_match_all('/\#/food/i', $unparsed, $parsed);

Also, how can I add conditions like matching: Food, FOOD & food ?


preg_match_all('/[#@]food\S*/i', $unparsed, $parsed);
0

精彩评论

暂无评论...
验证码 换一张
取 消