I have strings like this ' some-dasd\\dasd-dasdas\\dasdas-dasd-das\\dsad
'. I need to split the string to array by two different symbols '\\'
and '-'
, so I would like to get the array ['some', 'dasd', 'dasd', 'dasdas', 'dasdas', 'dasd', 'das' ,'dsad']
.
What is the best way to do it?
"ome-dasd\dasd-dasdas\dasdas-dasd-das\dsad".split(/\\|-/)
应该做的伎俩。
您可以使用regexp拆分字符串:
mystring.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.