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

首頁(yè) > 網(wǎng)站 > 幫助中心 > 正文

QString使用正則操作的接口實(shí)現(xiàn)

2024-07-09 22:42:19
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

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

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

contains

正則表達(dá)式rx是否與字符串中的某個(gè)地方匹配,匹配返回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

返回正則表達(dá)式rx在字符串中匹配的次數(shù)。

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

indexOf

返回字符串中正則表達(dá)式rx的第一個(gè)匹配項(xiàng)的索引位置,從索引位置向前搜索。如果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

返回字符串中正則表達(dá)式rx最后一個(gè)匹配項(xiàng)的索引位置,從索引位置向后搜索。如果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

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

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

replace

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

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

section

將字符串由正則表達(dá)式來(lái)分割字段序列。

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

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

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

splitRef

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

QVector<QStringRef> splitRef(const QRegExp &rx, QString::SplitBehavior behavior = KeepEmptyParts) constQVector<QStringRef> splitRef(const QRegularExpression &re, QString::SplitBehavior behavior = KeepEmptyParts) const
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 临猗县| 阳朔县| 阳原县| 科技| 斗六市| 行唐县| 枝江市| 大理市| 黎城县| 汉源县| 古田县| 蒙阴县| 海丰县| 沐川县| 疏附县| 富平县| 安康市| 武汉市| 连城县| 凯里市| 韩城市| 靖江市| 大渡口区| 陕西省| 奉新县| 定安县| 镇宁| 连山| 黔东| 浑源县| 城步| 陆丰市| 苍南县| 裕民县| 阳朔县| 于田县| 观塘区| 巴彦淖尔市| 嘉祥县| 和林格尔县| 比如县|