Regular Expressions 101

Community Patterns

匹配属性的对象

0

Regular Expression
PCRE (PHP <7.3)

/
\b([\w$]+(\([^()]*(\([^()]*\)[^()]*)*\)|\[[^\[\]]+\])?\.)+(?:host|hostname|href|protocol|origin|port)\b
/
gm

Description

该正则表示对的是匹配location对象下的 host、hostname、href、protocol、origin、port 属性前对象匹配, 例如匹配:

  1. a.href
  2. location.href
  3. getTop().location.href
Submitted by anonymous - 5 years ago