boost::algorithm::split_regex doesn't work with boost::u32regex.
還沒有人認領這個 Issue。
評估
研究方向
使用 CMakeLists.txt 設定重現 src.cpp 中的行為,並在 UTF-8 範例上比較 split_regex 與 u32regex_replace。從 boost::algorithm split_regex 進入點及其正規表示式處理開始;當範例被分割成預期的 token,且有回歸測試涵蓋此行為時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
I want to split a UTF-8 string into tokens. However it looks like that split_regex() failed and just return original string. I also tried u32regex_replace() and it indeed replaced successfully.
src.cpp:
// CutWord.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include<vector>
#include<string>
#include <boost/algorithm/string.hpp>
#include<boost/algorithm/string/regex.hpp>
#include <boost/regex/icu.hpp>
#include<regex>
using namespace std;
int main()
{
string str="数学。数学。数学。";
//Split
vector<string> vs;
//regexU3 stores expression.
boost::u32regex regexU32= boost::make_u32regex("。");
boost::split_regex(vs, str,regexU32);
cout<<vs.size()<<endl; //only return 1.
//Check if u32regex_replace works.
string nsub=".";
string nstr=u32regex_replace(str, regexU32, nsub);
cout<<nstr<<endl;
};
CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(main)
set(CMAKE_C_COMPILER /usr/bin/gcc CACHE PATH "" FORCE)
set(CMAKE_CXX_COMPILER /usr/bin/g++ CACHE PATH "" FORCE)
include_directories("/usr/local/include")
include_directories("./include")
add_executable(mp src.cpp)
#ICU
find_package(ICU COMPONENTS i18n io dt in uc)
target_link_libraries(mp ${ICU_LIBRARIES})
#boost
find_package( Boost COMPONENTS regex)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIR})
target_link_libraries( mp ${Boost_LIBRARIES} )
target_compile_features(mp PUBLIC cxx_std_20)
add_custom_command(TARGET mp POST_BUILD
COMMAND echo "----------------------------------------------"
COMMAND ./mp
COMMAND echo "----------------------------------------------")
- 主要語言
- C++
- 星號
- 131
- 分支
- 118
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
boostorg/algorithm 的其他 Issue
-
難度 5/5 一週以上 新手友好度 30/100
-
難度 5/5 一週以上 新手友好度 35/100
-
難度 5/5 一週以上 新手友好度 35/100
-
難度 5/5 一週以上 新手友好度 25/100
-
難度 4/5 3-5 天 新手友好度 25/100
查看 boostorg/algorithm 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
mesonbuild/wrapdb#2961 ·
維護者通常 1 天內回覆
-
80 Instance - Raid - Northrend
難度 2/5 1-3 小時 新手友好度 62/100
azerothcore/azerothcore-wotlk#28075 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
objectionary/eo-graphs#80 ·
-
難度 2/5 1-3 小時 新手友好度 84/100
scanaislop/aislop#476 ·
維護者通常 1 天內回覆