I want to split a string using "+" or "-" as delimiter.
test.split(/-/)
will split by "-". test.split(/\\+/)
will split by "+". I need to check for both of them.
只需使用一个字符类,然后在其中添加+
和-
。
puts test.split(/[+-]/);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.