boost::algorithm::split_regex doesn't work with boost::u32regex.
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the behavior from src.cpp using the CMakeLists.txt configuration, comparing split_regex with u32regex_replace on the UTF-8 sample. Start at the boost::algorithm split_regex entry point and its regex handling; done means the sample is split into the expected tokens and a regression test covers the behavior.
Written by the indexing model from the issue text.
Description
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 "----------------------------------------------")
- Dominant language
- C++
- Stars
- 131
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/algorithm
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Automated formatting Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
All issues in boostorg/algorithm
Similar issues
-
ai_reviewed
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ydb-platform/ydb#53869 · 3 comments ·
-
bug cert blocker needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
project-chip/connectedhomeip#74373 ·
-
upstream update
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
conan-io/conan-center-index#31035 ·
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 85/100
vllm-project/vllm-ascend#17329 ·