Computer Science Canada Regex, breaking apart a string. |
Author: | Martin [ Thu Nov 25, 2004 5:23 pm ] |
Post subject: | Regex, breaking apart a string. |
Suppose I had a string of characters and a dynamic array. Would there be any way, with regex, to break the string up into substrings seperated by specified characters? I guess the best example of this would be breaking up a sentence into words. |
Author: | wtd [ Thu Nov 25, 2004 7:12 pm ] | ||||
Post subject: | Re: Regex, breaking apart a string. | ||||
martin wrote: Suppose I had a string of characters and a dynamic array. Would there be any way, with regex, to break the string up into substrings seperated by specified characters?
I guess the best example of this would be breaking up a sentence into words. Well, basically, words are composed of letters, and possibly apostrophes. So we want to split on anything that isn't one of those characters. For this, we can use a negative set.
Now, in Ruby, for instance:
|
Author: | rizzix [ Thu Nov 25, 2004 9:18 pm ] | ||
Post subject: | Re: Regex, breaking apart a string. | ||
martin wrote: Suppose I had a string of characters and a dynamic array. Would there be any way, with regex, to break the string up into substrings seperated by specified characters?
I guess the best example of this would be breaking up a sentence into words. yes u can and in java its a matter of
|
Author: | Martin [ Thu Nov 25, 2004 11:08 pm ] |
Post subject: | |
Oh, perfect. Is there a way to do it in C++ though? |
Author: | wtd [ Thu Nov 25, 2004 11:09 pm ] |
Post subject: | |
martin wrote: Oh, perfect. Is there a way to do it in C++ though?
There is no standard regular expression library for C++. It is being included in the next C++ standard, from what I hear. |
Author: | Martin [ Thu Nov 25, 2004 11:43 pm ] |
Post subject: | |
Excellent. I have been reading your tutorials, wtd, I just don't reply because I don't want to mess up the order :p |
Author: | md [ Thu Nov 25, 2004 11:58 pm ] |
Post subject: | |
if you need a good string class martin I've written one you can use. In fact if you ever looked at the project you would see it... [edit] anyone else can get it from http://svn.nxor.org/ tis somewhere in hte BF-F project [edit #2] tis in BF-f/src/cString there is a header file and a source file |
Author: | wtd [ Fri Nov 26, 2004 12:05 am ] |
Post subject: | |
Cornflake wrote: if you need a good string class martin I've written one you can use. In fact if you ever looked at the project you would see it...
I don't see how this is better than std::string. |