zoukankan
html css js c++ java
利用正则来查找字符串中第n个匹配字符索引
1.string.IndexOf()方法可以获得第一个匹配项的索引
2.要获取第n个匹配项的索引:
方法1:利用
IndexOf
方法循环获取。
方法2:用正则来查找。
System.Text.RegularExpressions.MatchCollection matches = System.Text.RegularExpressions.Regex.Matches(input, query);
通过:matches[count].Index获取
其中: input:表示待查找的字符串,
query":匹配字符串,
count":第几个匹配项,从0开始。
查看全文
相关阅读:
hihocoder-Week216-Gas Stations
hihocoder-1740-替换函数
hihocoder-1732-1-偏差排列
hihocoder-Week200-Shorteniring Sequence
hihocoder-1720-小数数字
hihocoder-Week197-逆序单词
hihocoder-Week195-奖券兑换
hihocoder-Week184-满减优惠
word ladder-leetcode
数的划分
原文地址:https://www.cnblogs.com/VueDi/p/11913258.html
最新文章
恢复刷题后的感觉
ubuntu服务器与本地文件传输
ubuntu 安装tomcat<服务器>
ubuntu安装jdk<服务器>
ubuntu安装mysql<服务器>
素数筛
ubuntu完全卸载nginx
欧拉筛
寒假练习 04
寒假练习 03
热门文章
寒假练习 02
寒假练习 01
SGU[127] Telephone directory
SGU[112] a^b-b^a
SGU[113] Nearly prime numbers
SGU[107] 987654321 problem
SGU[184] Patties
SGU[135] Drawing Lines
hihocoder-1796-完美K倍子数组
hihocoder-Week219-Smallest Rectangle
Copyright © 2011-2022 走看看
通过:matches[count].Index获取
-
query":匹配字符串,
count":第几个匹配项,从0开始。