亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我該如何提取一串字符串里面的特定幾個子字符串?

我該如何提取一串字符串里面的特定幾個子字符串?

楊__羊羊 2023-03-03 18:14:50
比如01-01 06:11:25.424 462 462 D [xx_hal] : [xx__hal_authenticate] enter, group_id = 0,這是這個字符串的所有內容,我需要提取的有字符串1:01-01 06:11:25.424,這是世界內容,提取的有字符串2:xx_hal,這是模塊名字,字符串3:xx__hal_authenticate,這是函數,字符串4:enter, group_id = 0,這是內容
查看完整描述

1 回答

?
慕的地8271018

TA貢獻1796條經驗 獲得超4個贊

boostSTL補充regex其模塊各類別本文記錄用引入文件1.regex_matchregexreg("\\d{3}");stringstr="123";boolb=regex_match(str,reg);2.regex_replace(strings,regexe,stringt)s匹配e串替換tregexreg("(colo)(u)(r)",boost::regex::icase|boost::regex::perl);strings="Colour,colour,color,colOurize";s=regex_replace(s,reg,"$1$3");t$n代表reg第n括號內容$3表示r$1表示colo段代碼表示colour換colorboost::regex::icase/boost::regex::perl標志關表示忽略寫需要標志關打需要默認關閉regex_replace修改原字符串新串返3.erase_all_regex(string,regex)(boost::algorithm::erase_all_regexinheader)刪除滿足regex所串原串直接修改#includeerase_all_regex(str,boost::regex("[\n|\t|\r]"))刪除字符串str所空格4.split_regex(序列式容器,string,regex)()割符regex格式割string結存放容器#includevectorfields;split_regex(fields,str,boost::regex("[\\*|X]"));str="5*6"fields存放56str修改5.split(序列式容器,string,Predicate),()#include#includevectorresult;split(result,school_code,is_any_of(";"));is_any_of用于判斷school_code否包含";";割school_code存放result修改原串

查看完整回答
反對 回復 2023-03-06
  • 1 回答
  • 0 關注
  • 98 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號