Python理解正则表达式

时间:2015-07-27 05:07:09

标签: python regex

您好我正在阅读一些代码并发现re.compile("<@(U\S+)>"),我在理解<>方面遇到了一些麻烦。有人能给出一个匹配的例子吗?我曾尝试使用'<@U>''<@jyx>'的python交互式shell,但它们不匹配。感谢。

1 个答案:

答案 0 :(得分:5)

<>没有任何意义。

您必须提供<@U然后1 or more non space characters然后>才能匹配。

<@UASD>
<@US>

您的输入

<@U> did not match as no non space character present after U

<@asd> did not match as no U present after @