regex in swift is not working with this example?

后端 未结 1 1866
情歌与酒
情歌与酒 2021-01-28 06:15

I am trying to use Regex expressions but this does not work and I don\'t understand why. The println is not showing up in the output. I followed this tutorial to us

相关标签:
1条回答
  • 2021-01-28 07:03

    In this case, you do not need to use (/ ..... /ig)$, so try this:

       if let match = textField.text.rangeOfString("([a-z]+)|([0-9]+)", options: .RegularExpressionSearch) {
                    println("\(match) is bla bla bla...")
                }
    

    It will be work and return the range of the first occurrence of a given string

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