国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C > 正文

QString使用正則操作的接口實現

2020-01-26 13:23:07
字體:
來源:轉載
供稿:網友

介紹QString使用正則操作的接口。

Qt 5.0引入QRegularExpression,相比于QRegExp,前者修復了很多bugs,功能上也是兼容于QRegExp。推薦使用QRegularExpression。

contains

正則表達式rx是否與字符串中的某個地方匹配,匹配返回true,否則返回false。

bool contains(const QRegExp &rx) constbool contains(QRegExp &rx) constbool contains(const QRegularExpression &re) constbool contains(const QRegularExpression &re, QRegularExpressionMatch *match) const

count

返回正則表達式rx在字符串中匹配的次數。

int count(const QRegExp &rx) constint count(const QRegularExpression &re) const

indexOf

返回字符串中正則表達式rx的第一個匹配項的索引位置,從索引位置向前搜索。如果rx在任何地方都不匹配,則返回-1。

int indexOf(QRegExp &rx, int from = 0) constint indexOf(const QRegularExpression &re, int from = 0) constint indexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const

lastIndexOf

返回字符串中正則表達式rx最后一個匹配項的索引位置,從索引位置向后搜索。如果rx在任何地方都不匹配,則返回-1。

int lastIndexOf(QRegExp &rx, int from = -1) constint lastIndexOf(const QRegularExpression &re, int from = -1) constint lastIndexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const

remove

移除字符串中符合正則表達式rx的匹配,并返回對該字符串的引用。

QString &remove(const QRegExp &rx)QString &remove(const QRegularExpression &re)

replace

將字符串中符合正則表達式rx就替換為after字符串,并返回對該字符串的引用。

QString &replace(const QRegExp &rx, const QString &after)QString &replace(const QRegularExpression &re, const QString &after)

section

將字符串由正則表達式來分割字段序列。

QString section(const QRegExp ®, int start, int end = -1, QString::SectionFlags flags = SectionDefault) constQString section(const QRegularExpression &re, int start, int end = -1, QString::SectionFlags flags = SectionDefault) const

split

將字符串拆分為正則表達式rx匹配的子字符串,并返回這些字符串的列表。

QStringList split(const QRegExp &rx, QString::SplitBehavior behavior = KeepEmptyParts) constQStringList split(const QRegularExpression &re, QString::SplitBehavior behavior = KeepEmptyParts) const

splitRef

將字符串拆分為正則表達式rx匹配的子字符串引用,并返回這些字符串的列表。

QVector<QStringRef> splitRef(const QRegExp &rx, QString::SplitBehavior behavior = KeepEmptyParts) constQVector<QStringRef> splitRef(const QRegularExpression &re, QString::SplitBehavior behavior = KeepEmptyParts) const

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 高平市| 红河县| 稻城县| 丽江市| 手机| 临武县| 宽城| 高青县| 青海省| 同德县| 英德市| 西贡区| 谷城县| 柘荣县| 宝应县| 隆化县| 南川市| 宿州市| 左云县| 清原| 新泰市| 中阳县| 彭阳县| 衡东县| 泾川县| 凉城县| 新晃| 普陀区| 绍兴市| 周宁县| 宝坻区| 阿拉善左旗| 云梦县| 尚志市| 清涧县| 五常市| 神池县| 东海县| 博爱县| 蒙山县| 曲松县|