문제

I'm working on this regex:

/\{(\w+)::(\w+)::([\sa-zA-Z0-9]+)\}/

So, from a long string, I could get patterns like: Word::Word::Word and word and word

I've tested this regex here: http://regex101.com/

And in PHP it sais it should work fine.

But when I put into code, it doesn't work:

$pattern = '/\{(\w+)::(\w+)::([\sa-zA-Z]+)\}/';

echo preg_match_all(preg_match_all($pattern,'{WORD::WORD::PRUEB ASDF ASD}', $expr,PREG_PATTERN_ORDER));

the echo result is 0

도움이 되었습니까?

해결책

You are calling preg_match_all inside preg_match_all. Do this instead:

$pattern = '/\{(\w+)::(\w+)::([\sa-zA-Z]+)\}/';
echo preg_match_all($pattern,'{WORD::WORD::PRUEB ASDF ASD}', $expr, PREG_PATTERN_ORDER);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top