php - Regular expression: Get TeX commands -
i have string like:
$str = "\textaolig 3 \texthtbardotlessjvar \textrthooklong b \textbenttailyogh ; \textinvomega q \textscaolig . \textbktailgamma p \textinvsca r \textscdelta d \textctinvglotstop ! \textinvscripta s \textscf 2 \textctjvar \textlfishhookrlig t \textsck";
and wanna tex commands (\textaolig etc.) regular expression. tried:
\\([[a-z]\s]+)
but no luck. can me out?
kind regards,
first of all, have enclose string single quotes because when using double quotes if use backslash try escape character, isn't case.
secondly, have use \\\\
match backslash.
i don't know tex commands, i've tried match [\w\s\.;]+
correct if needed:
$str = '\textaolig 3 \texthtbardotlessjvar \textrthooklong b \textbenttailyogh ; \textinvomega q \textscaolig . \textbktailgamma p \textinvsca r \textscdelta d \textctinvglotstop ! \textinvscripta s \textscf 2 \textctjvar \textlfishhookrlig t \textsck'; preg_match_all('/\\\\(?p<tex>\w+)/s', $str, $m); var_dump($m["tex"]);
Comments
Post a Comment