Re: Challenge - Regular Expression that divides a string at tokens
- From: Roger Frost <RogerFrost@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 14 Feb 2009 13:05:01 -0800
Thanks for the reply Reece.
I've worked out various solutions to do this with methods on the string
class, such as split(), but they all lead to a very ugly series of more
string method calls. This is one reason why I need to use Regular
Expressions specifically.
The input string could begin with a token, and tokens can be nested (see the
example program), or could have zero tokens, or could be only tokens with no
literal text at all.
The ending algorithm is recursive object creation, and "inbetween" creation
I need to keep the string manipulation to a brutal minimum.
Your solution is a perfect workaround for the information you had, but this
is why I specifically said Regular Expressions. I'm not criticizing you,
infact that's good thinking! Do you have any idaes that use pure RegEx?
Thanks and keep up the good work,
Roger
"Reece" wrote:
Not answering your question as asked, but it seems to me it would be trivial
to do what you want using Mystring.Split(array) where your array has "{" and
"}" in it. Then you could re-concatenate those as would be appropropriate.
Thus you would get an array like:
"This is "
"blue"
", this is "
"red"
", and this is "
"green"
"."
and without much thinking I think you could figure out how to make all the
odd numbered elements of that array start with "{" and end with "}".
Good luck.
Reece
.
- References:
- Prev by Date: Re: Challenge - Regular Expression that divides a string at tokens
- Next by Date: Re: I need to list all the open, visible windows. XP.
- Previous by thread: Re: Challenge - Regular Expression that divides a string at tokens
- Next by thread: RE: Challenge - Regular Expression that divides a string at tokens
- Index(es):
Relevant Pages
|