[英]Regex split into words and punctuation/symbols
I have the following input: 我有以下输入:
func add(var a:Int, var b:Int) -> Int
{
return a + b
}
I'm using this Regex \\s*\\b\\s*
which I found online which is supposed to split up words and punctuation/symbols. 我使用
\\s*\\b\\s*
是我在网上找到的Regex \\s*\\b\\s*
,用于分隔单词和标点符号。 I tried it and it split up the input to 我尝试了一下,然后将输入拆分为
func
add
(
var
...
Which is working exactly how I want it to, until it finds the ->
sign, where it outputs 这正是我想要的工作方式,直到找到
->
符号,然后输出
:
Int
) ->
...
Everything else works fine but I would like it to output 其他一切正常,但我想输出
)
-
>
instead. 代替。
How can I achieve this? 我该如何实现? Thank you in advance.
先感谢您。
由于我不完全知道您正在使用哪个版本的regexp以及正在运行的命令来对其进行验证,因此我无法完全确定这是否可以解决您的问题,但是应该。
\s*(\b|[->])\s*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.