开发者

exact meaning of tag filtering regex

next regular expression filters some html tags' style/src attribute.

[(?i:s\\*c\\*r\\*i\\*p\\*t)]
[(?i:e\\*x\\*p\\*r\\*e\\*s\\*s\\*i\\*o\\*n)]

Besides 'modifier span',

what is "\\*"?

Does i开发者_如何学运维t mean s*c*r*i*p*t ? Then, does it have any effect to filtering?


In regex, \\* means 0 or more literal \ characters. So the regexes are looking for the words script and expression, possibly with any number of backslashes between the letters, and possibly with no backslashes at all.

Some examples that would match:

  • s\c\r\\ipt
  • sc\\\\\ript
  • s\\\c\r\\\ip\\\t
  • script

As Qtax points out, the language is going to be important here. I don't recognize that regex syntax, but some require backslashes to be double-escaped: once for the primary language, and once for the regex engine. That's a hard thing to explain, but basically it means that the patterns might only match the following two inputs, depending on the programming language:

  • s*c*r*i*p*t
  • e*x*p*r*e*s*s*i*o*n


Generally, a \ character in regex escapes special characters to suppress their special meaning.i.e \n would actually equate to \n instead of newline.

Simple as that!

Just to add to the answer, the characters in question would resolve to s\*c\*r\*i\*p\*t

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜