괄호 안의 텍스트를 잡을 방법 :내가 괄호 안에 텍스트를 캡처하는이 작은 코드가
$string = '[title=my title] http://bit.ly/gANFxi [maps:some cool place]';
preg_match_all('/\[([^\]]*)\]/', $string, $matches);
print_($matches[0]);
내가 도착하면 다음과 같다 :
나는 "피하기 위해 더 제한 만들고 싶어Array( [0] => [title=my title] [1] => [maps:some cool place] )
[some-not cool] "또는"[another + stuff] ", 그래서 나는 [some : thing]과 [some = thing] 만 잡아야합니다.
어떻게하면됩니까? ':'무시 기타 :
$string = '[title=my title] http://bit.ly/gANFxi [maps:some cool place] [some-not cool] or [another+stuff]';
preg_match_all('/\\[([^\\]]*[\\=|\\:][^\\]]*)\\]/', $string, $matches);
print_r($matches[0]);
이 트릭을 할합니까
: $)를 선택한 다음, 다음 코드를 사용할 수 있습니다! 감사합니다 : D – greenbandit
세계는 더 많은 정규 표현식 전문가가 필요합니다 –
@ AdamSack, 세계는 더 많은 Chomskys가 필요합니다. – Godwin