我有一个正则表达式可以从推文中删除所有用户名。它看起来像这样:
regexFinder = "(?:\\s|\\A)[@]+([A-Za-z0-9-_]+):";
我试图了解每个组件的作用。到目前为止,我有:
( Used to begin a “group” element
?: Starts non-capturing group (this means one that will be removed from the final result)
\\s Matches against shorthand characters
| or
\\A Matches at the start of the string and matches a position as opposed to a character
[@] Matches against this symbol (which is used for Twitter usernames)
+ Match the previous followed by
([A-Za-z0-9- ] Match against any capital or small characters and numbers or hyphens
不过,我对最后一点有点迷失了。有人能告诉我 +): 是什么意思吗?我假设括号结束了该组,但我没有得到冒号或加号。
如果我对正则表达式的理解有任何错误,请随时指出!