Im looking for JavaScript equivalent RegExp for PHP.
This PHP RegExp class must have same methods with same returns as JavaScript version.
I can not find anything.
Thanks
[EDIT]
I need same class in PHP as is in JavaScript. preg_match methods in php has different results as RegExp.exec in JavaScript. And also has different flags
You can use Javascript RegExp
object in order to accomplish what you want.
Here's an example taken from MDN:
var re = /(\w+)\s(\w+)/;
var str = 'John Smith';
var newstr = str.replace(re, '$2, $1');
console.log(newstr);
You can check more of them here .
I really don't believe you searched all that hard. Top google result for "PHP RegEx": http://php.net/manual/en/function.preg-match.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.