preg-match

Convert Javascript regex to PHP regex?

六眼飞鱼酱① 提交于 2020-04-20 14:05:26
问题 I'm using the following regex from emailregex.com to validate emails on my site. It's working like a charm in JS but I'm unable to get it working within PHP. /^(([^<>()[]\.,;:\s@"]+(.[^<>()[]\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/ The issue from what I'm seeing is the backslashes, when adding it in quotes it keeps trying to escape it. Regex101 shows that it is working, it's just a matter of how to get it into PHP. Any help

Convert Javascript regex to PHP regex?

寵の児 提交于 2020-04-20 14:04:31
问题 I'm using the following regex from emailregex.com to validate emails on my site. It's working like a charm in JS but I'm unable to get it working within PHP. /^(([^<>()[]\.,;:\s@"]+(.[^<>()[]\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/ The issue from what I'm seeing is the backslashes, when adding it in quotes it keeps trying to escape it. Regex101 shows that it is working, it's just a matter of how to get it into PHP. Any help

Convert Javascript regex to PHP regex?

两盒软妹~` 提交于 2020-04-20 14:02:52
问题 I'm using the following regex from emailregex.com to validate emails on my site. It's working like a charm in JS but I'm unable to get it working within PHP. /^(([^<>()[]\.,;:\s@"]+(.[^<>()[]\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/ The issue from what I'm seeing is the backslashes, when adding it in quotes it keeps trying to escape it. Regex101 shows that it is working, it's just a matter of how to get it into PHP. Any help

Convert Javascript regex to PHP regex?

走远了吗. 提交于 2020-04-20 14:02:13
问题 I'm using the following regex from emailregex.com to validate emails on my site. It's working like a charm in JS but I'm unable to get it working within PHP. /^(([^<>()[]\.,;:\s@"]+(.[^<>()[]\.,;:\s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/ The issue from what I'm seeing is the backslashes, when adding it in quotes it keeps trying to escape it. Regex101 shows that it is working, it's just a matter of how to get it into PHP. Any help

preg_match unknown modifier '.' in wordpress [duplicate]

…衆ロ難τιáo~ 提交于 2020-02-25 07:59:23
问题 This question already has answers here : Warning: preg_replace(): Unknown modifier ']' (3 answers) Closed 8 months ago . I'm trying to do something simple...I thought? Have the following... $current = '/zeta/2010/03/'; preg_match('/zeta/.{4}/(.{2})/$',$current,$monthnum); Simply am trying to make $monthnum = 03 Keep either getting an unknown modifier error or, when I add the delimiters '#/zeta/.{4}/(.{2})/$# it returns with simply #Array ... Can anyone help? 回答1: PCREs have to be enclosed in

Java & PHP - preg_match

烂漫一生 提交于 2020-02-25 03:58:56
问题 What is the exact equivalent of PHP preg_match($pattern, $text) in JAVA ? I got different result for same text input as well as regex pattern in following php & java program. Regex - \b(?:(?>cancer()|problem()|(?>\1|\2)\w+)\b\W*?){0,3}\1\2 do match term -"cancer problem" within number Of words. here this is {0,3} PHP <?php $text = "doctors found many cancer related chest problems in japan during second world war."; $pattern = "/\\b(?:(?>cancer()|problem()|(?>\\1|\\2)\\w+)\\b\\W*?){0,3}\\1\\2

Java & PHP - preg_match

寵の児 提交于 2020-02-25 03:58:31
问题 What is the exact equivalent of PHP preg_match($pattern, $text) in JAVA ? I got different result for same text input as well as regex pattern in following php & java program. Regex - \b(?:(?>cancer()|problem()|(?>\1|\2)\w+)\b\W*?){0,3}\1\2 do match term -"cancer problem" within number Of words. here this is {0,3} PHP <?php $text = "doctors found many cancer related chest problems in japan during second world war."; $pattern = "/\\b(?:(?>cancer()|problem()|(?>\\1|\\2)\\w+)\\b\\W*?){0,3}\\1\\2

Java & PHP - preg_match

拜拜、爱过 提交于 2020-02-25 03:58:29
问题 What is the exact equivalent of PHP preg_match($pattern, $text) in JAVA ? I got different result for same text input as well as regex pattern in following php & java program. Regex - \b(?:(?>cancer()|problem()|(?>\1|\2)\w+)\b\W*?){0,3}\1\2 do match term -"cancer problem" within number Of words. here this is {0,3} PHP <?php $text = "doctors found many cancer related chest problems in japan during second world war."; $pattern = "/\\b(?:(?>cancer()|problem()|(?>\\1|\\2)\\w+)\\b\\W*?){0,3}\\1\\2

How to retrieve variable=“value” pairs from m3u string

两盒软妹~` 提交于 2020-02-16 08:26:29
问题 I have m3u file that contain lines like example: #EXTINF:0 $ExtFilter="Viva" group-title="Variedades" tvg-logo="logo/Viva.png" tvg-name="Viva" I run this in PHP with no success: preg_match('/([a-z0-9\-_]+)=\"([a-z0-9\-_\s.]+)\"\s+/i',$str,$matches) I want to get: $matches[0] = $ExtFilter $matches[1] = Viva $matches[2] = group-title $matches[3] = Variedades $matches[4] = tvg-logo $matches[5] = logo/Viva.png $matches[6] = tvg-name $matches[7] = Viva I try regexp tools (like this). Thank u. 回答1:

How to retrieve variable=“value” pairs from m3u string

≯℡__Kan透↙ 提交于 2020-02-16 08:26:00
问题 I have m3u file that contain lines like example: #EXTINF:0 $ExtFilter="Viva" group-title="Variedades" tvg-logo="logo/Viva.png" tvg-name="Viva" I run this in PHP with no success: preg_match('/([a-z0-9\-_]+)=\"([a-z0-9\-_\s.]+)\"\s+/i',$str,$matches) I want to get: $matches[0] = $ExtFilter $matches[1] = Viva $matches[2] = group-title $matches[3] = Variedades $matches[4] = tvg-logo $matches[5] = logo/Viva.png $matches[6] = tvg-name $matches[7] = Viva I try regexp tools (like this). Thank u. 回答1: