can converting php regex pattern javascript compatible one? php preg_match_all('/(?ims)([a-z0-9\s\.\:#_\-@,]+)\{([^\}]*)\}/', $data, $matches); javascript matches=data.match(/(?ims)([a-z0-9\s\.\:#_\-@,]+)\{([^\}]*)\}/); thanks to mimic php output, need @ more regular expression. single match, javascript match method trick, multiple matches no longer return captured groups. in fact, there no out-of-the-box statement in javascript equivalent preg_match_all . the method comes closest regex.exec , being method can both return captured groups , multiple matches. not return matches in 1 go. instead need iterate on them, instance this: for (matches = []; result = regex.exec(data); matches.push(result)); now regular expression needs adjustments: in javascript modifiers ( ims ) cannot specified have it, must specified @ end, after closing slash. note in php can same. secondly, javascript has no support s modifier. in case not problem, regular expressio...
Comments
Post a Comment