정규식 사용법 [펌] boost 사용

질문 ::#이 붙은 전화 번호 앞에는 %23을 붙이고 싶음..

 

답코드 ::

std::string result, list = “#011-222-3333”;

const char* regStr = “(#)?(01[016789])-?(d{3,4})-?(d{4})”;
const char* subStr = “(?1%23)$2$3$4”;

boost::regex_replace(result, list.begin(), list.end(), regStr, subStr, boost::match_default | boost::format_all);

std::cout << result << std::endl;
[url]http://www.boost.org/libs/regex/doc/regex_replace.html[/url]
[url]http://ourworld.compuserve.com/homepages/John_Maddock/[/url]
[url]http://research.microsoft.com/projects/greta/gretauserguide.htm[/url]