-
regex.h
I need to find a method in c++ to split a c++ string based on the occurence of a regular expression.
In case that's confusing;
My goal is to set up a vector <string> to recieve the value. the value is returned based on a regular expression. If the string were (quotes for clarity) "hello, world" this supposed method would return {"hello,","world"} if the regular expression given were a space.
I've tried calling this supposed method (split) from the libraries string and regex.h by saying
Code:
string str=txt.split(",")
or something of that nature.
anyone know of such a method?
-
cstring's strtok() can do that, but your regular expression would have to be a single character. You'd just need to access the C-style string contained in your string object. If your needs get too specific, you could always write your own function ;)
-
The Boost libraries contain both simple string tokenizing and full-blown regular expression matching.
-
wats the syntax for strtok?
-