这个正则表达式匹配什么? /([^" ^ \ S] +)\ S * |"([^"] +)" \ S * /克

时间:2012-03-31 13:34:05

标签: regex alfresco

我现在应该能够阅读一个正则表达式,但是所有人都可以通过它来谈论我吗?

/([^"^\s]+)\s*|"([^"]+)"\s*/g

仅供参考;它在Alfresco中用于匹配文档标签。有没有一个网站,你可以插入这些网站并获得解释(除了SO)!

2 个答案:

答案 0 :(得分:6)

(        # start a capture group
[^"^\s]+ # one or more characters NOT quote, caret, or white space
)        # close capture group
\s*      # followed by optional white space
|  # either match everything before this '|' or everything after it
"        # match a quote character
(        # start capture group
[^"]+    # one or more characters NOT quote
)        # close capture group
"        # the closing quote
\s*      # followed by optional white space

正如Blindy所说,它要么匹配一个没有'^',引号或空格的字符串,要么它匹配两个引号字符之间的所有内容。并且它保存了它在反向引用中发现的内容(我称之为'群组',因为我的Python卡在我脑海中)。

答案 1 :(得分:2)

它匹配标识符(不包含"^或任何类似空格的字符 - 空格,制表符,新行)或引号之间的内容,或者后跟任意数量的空格。