Re: Challenge - Regular Expression that divides a string at tokens

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


.



Relevant Pages

  • Re: Declaring a dynamic pointer to an array of char pointers
    ... I'll expect a variable length string of tokens seperated by white space chars. ... I have read several web documents, pointer tutorials... ... Note that if you could use C++, vectorwould be better choice than raw C-like array of pointers. ...
    (microsoft.public.vc.language)
  • Re: Challenging text masking problem
    ... > create an array of integers representing the positions of %x tokens. ... It returns an array. ... When you split the output string into an array, all you need do is loop through ...
    (microsoft.public.dotnet.languages.vb)
  • WSE402: The message does not conform to the policy it was mapped t
    ... WSE 2 SP3 webservice that is requiring client side certs and username tokens: ... The message does not conform to the policy it was mapped to. ... expression, SoapEnvelope message, EndpointReference endpoint, String action, ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: Challenge - Regular Expression that divides a string at tokens
    ... Thus you would get an array like: ... I need to split a given string into sub-strings ... Now, I can do this in two parts, seperating the tokens from the literals ...
    (microsoft.public.dotnet.languages.csharp)
  • Bytecode source
    ... You can compile bytecode and get Forth code ... But it will probably be fast to compress and to decompress, ... Forth word with the string token followed by the length followed by the ... those must be made to store tokens instead of strings. ...
    (comp.lang.forth)