Is there a function that returns index where RegEx match starts?

后端 未结 6 442
栀梦
栀梦 2020-12-29 02:10

I have strings of 15 characters long. I am performing some pattern matching on it with a regular expression. I want to know the position of the substring where the IsM

6条回答
  •  一向
    一向 (楼主)
    2020-12-29 02:52

    Regex.Match("abcd", "c").Index
    
    2
    

    Note# Should check the result of Match.success, because its return 0, and can confuse with Position 0, Please refer to Mark Byers Answer. Thanks.

提交回复
热议问题