Swift regular expression format?

后端 未结 1 357
离开以前
离开以前 2020-12-06 16:18

I\'m familiar with doing pcre regexes, however they don\'t seem to work in swift.

^([1-9]\\d{0,2}(\\,\\d{3})*|([1-9]\\d*))(\\.\\d{2})?$

to

1条回答
  •  南方客
    南方客 (楼主)
    2020-12-06 17:08

    Within double quotes, a single backslash would be readed as an escape sequence. You need to escape all the backslashes one more time in-order to consider it as a regex backslash character.

    "^([1-9]\\d{0,2}(,\\d{3})*|([1-9]\\d*))(\\.\\d{2})?$" 
    

    0 讨论(0)
提交回复
热议问题