PHPH |如何使用正则表达式来逃避这个长字符串?

时间:2016-08-13 18:05:25

标签: php regex string escaping

是否有人在PHP中使用正则表达式并且知道如何逃脱它们?我今天尝试编写我的第一个正则表达式,但我没能正确地逃避它。

这是我想要选择的字符串(输入字符串中的单个字符串):

$(this).load(urlStr, data, function (response, innerstatus, xhr) {
                    status = innerstatus;
                    pb.hide();
                    sbmt_btn.show();
                    if (status == "error") {
                        var msg = "Sorry but there was an error: ";
                        $(this).html(msg + xhr.status + " " + xhr.statusText);
                    }
                    if ($('#NoMoreSearchForYou').get(0)) {
                        $('.ui-dialog-buttonset').hide();
                    }
                    else if ($('#MoreSearchForYou').length > 0) {
                        $('.ui-dialog-buttonset').show();
                    }
                    else {
                        $('.ui-dialog-buttonset').hide();
                    }
                });

这是我使用的正则表达式字符串 - 经过测试(参见现场演示):http://regexr.com/3e0qv

/\$\(this.+[\s\S]*hide\(\);[\s\S]{49};/m

属于目标字符串的字符:

), $, hide, (, ), ;

对它们如何工作的解释也会有很大帮助。

preg_quote并且手工制作的逃脱对我不起作用。 我非常感谢你的帮助!我坚持这个。

0 个答案:

没有答案
相关问题