




版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
■■◆類類類算法regex_matchregex_search迭代器regex_iterator■■類類算法regex_matchregex_search迭代器regex_iteratortemplate<classcharT,classtraits=regex_traits<charT>classbasic_regex//explicitexplicitbasic_regex(constcharT*flag_typef=basic_regex(constcharT*p1,constcharT*p2,flag_typef=regex_constants::normal);basic_regex(constcharT*p,size_typelen,flag_typebasic_regex(consttemplate<classST,classexplicitbasic_regex(constbasic_string<charT,ST,SA>&p,flag_typef=regex_constants::normal);template<classInputIterator>basic_regex(InputIteratorfirst,InputIteratorlast,flag_typef=basic_regex&operator=(constbasic_regex&);basic_regex&operator=(constcharT*ptr);
template<classST,classbasic_regex&operator=(constbasic_string<charT,ST,basic_regex&assign(constbasic_regex&that);basic_regex&assign(constcharT*ptr,flag_typef=regex_constants::normal);basic_regex&assign(constcharT*ptr,unsignedintlen,flag_typef);template<classstring_traits,classA>basic_regex&assign(constbasic_string<charT,string_traits,A>&s,flag_typef=regex_constants::normal);template<classInputIterator>basic_regex&assign(InputIteratorfirst,InputIteratorflag_typef=////std::pair<const_iterator,subexpression(size_typen)const_iteratorbegin()const;const_iteratorend()const;//size_typesize()const;size_typemax_size()const;boolempty()const;unsignedmark_count()const;stringstr()◆usingboost::regex;regexe1;e1="^[[:xdigit:]]*$";cout<<e1.str()<<endl;cout<<e1.mark_count()<<endl;//regexe2("\\b\\w+(?=ing)\\b.{2,}?([[:alpha:]]*)$",regex::perl|regex::icase|cout<<e2.str()<<cout<<e2.mark_count()<<endl;//如果regexe2未設subexpression()pair<regex::const_iterator,regex::const_iterator>sub1stringsub1Str(sub1.first,++sub1.second);cout<<sub1Str<<endl;類類算法regex_matchregex_search迭代器regex_iterator●●●template<classclassAllocator=std::allocator<sub_match<BidirectionalIterator>classmatch_results//explicitmatch_results(constAllocator&a=match_results(constmatch_results&match_results&operator=(constmatch_results&//size_typesize()const;size_typemax_size()const;boolempty()const;//template<classclassAllocator=std::allocator<sub_match<BidirectionalIterator>>classmatch_results{//typedefsub_match<BidirectionalIterator>value_type;typedefconstvalue_type&const_reference;typedefconst_reference////elementdifference_typelength(intsub=0)const;difference_typelength(constchar_type*sub)const;template<classcharT>difference_typelength(constcharT*sub)const;template<classcharT,classTraits,classA>difference_typelength(conststd::basic_string<charT,Traits,A>&sub)difference_typeposition(unsignedintsub=0)const;difference_typeposition(constchar_type*sub)const;template<classcharT>difference_typeposition(constcharT*sub)const;template<classcharT,classTraits,classA>difference_typeposition(conststd::basic_string<charT,Traits,A>&sub)string_typestr(intsub=0)const;string_typestr(constchar_type*sub)const;template<classTraits,classA>string_typestr(conststd::basic_string<char_type,Traits,A>&sub)const;template<classstring_typestr(constcharT*template<classcharT,classTraits,classstring_typestr(conststd::basic_string<charT,Traits,A>&const_referenceoperator[](intn)const;const_referenceoperator[](constchar_type*n)const;template<classTraits,classA>const_referencestd::basic_string<char_type,Traits,A>&n)const;template<classcharT>const_referenceoperator[](constcharT*n)const;template<classcharT,classTraits,classA>const_referenceoperator[](conststd::basic_string<charT,Traits,A>&n)const_referenceprefix()const_referencesuffix()const;const_iteratorbegin()const;const_iteratorend()const;//template<classOutputIterator,classFormatter>OutputIteratorformat(OutputIteratorout,Formattermatch_flag_typeflags=format_default)const;template<classFormatter>string_typeformat(Formattermatch_flag_typeflags=format_default)allocator_typeget_allocator()const;voidswap(match_results&that);match_results<constmatch_results<constusingusingregexe1("\\bT\\w+\\bstrings("Timeef09,Todo001");boost::smatchm;boolb=boost::regex_search(s,m,e1,boost::match_all);cout<<b<<endl;constintn=for(inti=0;i<n;++i)cout<<"matched"<<i<<"position:<<m.position(i)<<",cout<<"length:"<<m.length(i)<<",str:";cout<<m.str(i)<<endl;}類類算法regex_matchregex_search迭代器regex_iterator●template<classclasssub_match:publicstd::pair<BIter,BIter>typedeftypenameiterator_traits<BIter>::value_typetypedeftypenameiterator_traits<BIter>::difference_typetypedefBIterbooldifference_typelength()operatorbasic_string<value_type>()const;basic_string<value_type>str()const;intcompare(constsub_match&s)intcompare(constbasic_string<value_type>&s)const;intcompare(constvalue_type*s)const;-■類類類迭代器regex_iterator■■●●●template<classBIter,classAllocator,classcharT,classtraits>boolregex_match(BIterfirstBIterlast,match_results&m,//保存匹配結果constregex&e,match_flag_typeflags=template<classBIter,classcharT,classtraits>boolregex_match(BIterfirst,BIterlast,constregex&match_flag_typeflags=template<classcharT,classAllocator,classtraits>boolregex_match(constcharT*str,match_results&m,constregex&match_flag_typeflags=template<classcharT,classtraits>boolregex_match(constcharT*str,constregex<charT,traits>&e,match_flag_typeflags=match_default);template<classST,classSA,classAllocator,classcharT,classtraits>boolregex_match(conststring&s,match_results&m,//保存匹配結果constregex&e,match_flag_typeflags=template<classST,classSA,classcharT,classtraits>boolregex_match(conststring&s,constregex&match_flag_typeflags=usingusingboost::regex;regexstringwhile(getline(cin,line))if(line==if(regex_match(line,e,boost::match_default))cout<<"Matched"<<endl;cout<<"NoMatch"<<}●●●template<classBIter,classAllocator,classcharT,classtraits>boolregex_search(BIterfirst,BIterlast,match_results&m,//保存匹配結果constregex&e,match_flag_typeflags=template<classBIter,classcharT,classtraits>boolregex_search(BIterfirst,BIterlast,constregex&match_flag_typeflags=template<classcharT,classAllocator,classtraits>boolregex_search(constcharT*str,match_results&m,constregex&match_flag_typeflags=template<classcharT,classtraits>boolregex_search(constcharT*constregex<charT,traits>&e,match_flag_typeflags=match_default);template<classST,classSA,classAllocator,classcharT,classtraits>boolregex_search(conststring&s,match_results&m,//保存匹配結果constregex&e,match_flag_typeflags=template<classST,classSA,classcharT,classtraits>boolregex_search(conststring&s,constregex&match_flag_typeflags=usingregexe1("\\bT\\w+\\bstrings("Timeef09,Todo001");boost::smatchm;boolb=boost::regex_search(s,e1,cout<<*(m[1].first)<<''<<*(m[1].second)<<endl;cout<<"-----------------------"<<endl;constintn=for(inti=0;i<n;++i)cout<<"matched"<<i<<"position:<<m.position(i)<<",cout<<"length:"<<m.length(i)<<",str:";cout<<m.str(i)<<endl;}template<classOIter,classBIter,classtraits,classOIterregex_replace(OIterout,BIterfirst,BIterconstregex&Formattermatch_flag_typeflags=template<classtraits,classFormatter>stringregex_replace(conststring&s,constregex&e,Formatterfmt,match_flag_typeflags=match_default);usingregexstringreplaceFmt("(\\L?1$&)(?2+)(?3#)");stringsrc("guTdQhV@@g*b*");cout<<"beforereplaced:"<<src<<stringnewStr1=regex_replace(src,e1,boost::match_default|boost::format_all);cout<<"afterreplaced:"<<newStr1<<endl;stringnewStr2=regex_replace(src,e1,boost::match_default|boost::format_default);cout<<"afterreplaced:"<<newStr2<<endl;ostream_iterator<char>regex_replace(oi,src.begin(),src.end(),e1,replaceFmt,boost::match_default|boost::format_all);-■類類類算法regex_matchregex_search■■template<classBIter,classcharT=classtraits=regex_traits<charT>classregex_iteratortypedefbasic_regex<charT,traits>typedefmatch_results<BIter>typedeftypenameiterator_traits<BIter>::difference_typetypedefconstvalue_type*typedefconstvalue_type&typedefstd::forward_iterator_tagregex_iterator(BItera,BIterb,constregex_type&re,match_flag_typem=match_default);regex_iterator(constregex_iteratorregex_iterator&operator=(constregex_iterator&);booloperator==(constregex_iterator&)const;booloperator!=(constregex_iterator&)const;constvalue_type&operator*()const;constvalue_type*operator->()const;regex_iterator&operator++();regex_iteratoroperator++(int);typedefregex_iterator<constchar*>cregex_iterator;typedefregex_iterator<std::string::const_iterator>#ifndeftypedefregex_iterator<constwchar_t*>wcregex_iterator;typedefregex_iterator<std::wstring::const_iterator>template<classcharT,classtraits>regex_iterator<constcharT*,charT,traits>make_regex_iterator(constcharT*p,constregex&e,regex_constants::match_flag_typem=template<classcharT,classtraits,classST,classSA>regex_iterator<typenamestring::const_iterator,charT,traits>make_regex_iterator(conststring&p,constregex<charT,traits>&e,regex_constants::match_flag_typem=usingusingregexe("(a+).+?",regex::icase);strings("annabbaaat");boost::sregex_iteratorit1(s.begin(s.ende);boost::sregex_iteratorit2;//結束迭代器for(;it1!=it2;{boost::smatchm=*it1;cout<<m<<endl;}template<classBIter,classcharT=classtraits=regex_traits<charT>classregex_token_iteratortypedefbasic_regex<charT,traits>typedefsub_match<BIter>//regex_token_iterator(BItera,BIterb,constregex_type&re,intsubmatch=0,match_flag_typem=match_default);regex_token_iterator(BItera,BIterconstregex_type&conststd::vector<int>&submatches,match_flag_typem=template<std::size_tN>regex_token_iterator(BItera,BIterb,constregex_type&re,constint(&submatches)[N],match_flag_typem=match_default);regex_token_iterator(constregex_token_iterator&);regex_token_iterator&operator=(constbooloperator==(constregex_token_iterator&)const;booloperator!=(constregex_token_iterator&)const;constvalue_type&operator*()const;constvalue_type*operator->()const;regex_token_iterator&operator++();regex_token_iteratoroperator++(int);typedefregex_token_iterator<constchar*>typedefregex_token_iterator<std::string::const_iterator>#ifndeftypedefregex_token_iterator<constwchar_t*>typedefregex_token_iterator<<std::wstring::const_iterator>template<classcharT,classtraits>regex_token_iterator<constcharT*,charT,traits>make_regex_token_iterator(constcharT*p,constbasic_regex<charT,traits>&e,intsubmatch=0,regex_constants::match_flag_typem=template<classcharT,classtraits,classST,classSA>regex_token_iterator<typenamestring::const_iterator,charT,make_regex_token_iterator(conststring&p,constbasic_regex<charT,traits>&e,intsubmatch=0,regex_constants::match_flag_typem=template<classcharT,classtraits,std::size_tN>regex_token_iterator<constcharT*,charT,traits>constcharT*constbasic_regex<char
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 縣城燒烤設備租賃合同范本
- 北京私家車租借合同范本
- 廠區(qū)網(wǎng)絡監(jiān)控安裝合同范例
- 合同范本協(xié)商
- 凍貨運輸合同范本
- 合同范例大英文
- 合同范本和公司經(jīng)營范本
- 加入俱樂部合同范本
- 辦公配件合同范本
- 合同屬于無效合同范本
- 現(xiàn)代家政導論-課件 4.2.2國外家庭教育
- 金波讀書樂課件
- 2《中國老年糖尿病診療指南(2024年版)》解讀
- 2024年北京中考地理試卷
- 四川蜀道集團筆試題
- 零食門市轉(zhuǎn)讓協(xié)議書范本
- 電氣自動化工程師考試題庫
- 小學利潤問題應用題100道附答案(完整版)
- 醫(yī)院智能化系統(tǒng)內(nèi)網(wǎng)、外網(wǎng)及設備網(wǎng)系統(tǒng)拓撲圖-可編輯課件
- 小學生心理健康主題家長會
- 社交禮儀-儀態(tài)禮儀
評論
0/150
提交評論