0

I have a particular problem in complex string:

string mode:

     Description,Title,ContentFooterLeft[JE_Boxes: Identifier,Box,Namespace,Title,Channels,PriorityChannels,ForceChannel,SingleQuery,Template,Elements[JE_Example: Lead],LastNews[JE_Article: Lead, Galeria [JE_Gallery: Title,Banner [JE_Banner: Title],],],],Keywords

Tree mode:

Description,
Title,
ContentFooterLeft
    [
        JE_Boxes: 
                Identifier,
                Box,
                Namespace,
                Title,
                Channels,
                PriorityChannels,
                ForceChannel,
                SingleQuery,
                Template,
                Elements
                    [
                        JE_Example:
                                Lead
                    ],
                LastNews
                    [
                        JE_Article: 
                                Lead,
                                Galeria
                                    [
                                        JE_Gallery:
                                                Title,
                                                Banner 
                                                    [
                                                        JE_Banner: 
                                                                Title
                                                    ],
                                    ],
                    ],
    ],
Keywords

And my objective with Regex.Split its something like this:

1º [Step] Call function:

Regex.Split("Description,Title,ContentFooterLeft[JE_Boxes: Identifier,Box,Namespace,Title,Channels,PriorityChannels,ForceChannel,SingleQuery,Template,Elements[JE_Example: Lead],LastNews[JE_Article: Lead, Galeria [JE_Gallery: Title,Banner [JE_Banner: Title],],],],Keywords", "Regex expression")

1º Result:

Description
Title
ContentFooterLeft[JE_Boxes:Identifier,Box,Namespace,Title,Channels,PriorityChannels,ForceChannel,SingleQuery,Template,Elements[JE_Example: Lead],LastNews[JE_Article: Lead, Galeria [JE_Gallery: Title,Banner [JE_Banner: Title],],],]
Keywords

2º [Step] Call function:

Regex.Split("ContentFooterLeft[JE_Boxes:Identifier,Box,Namespace,Title,Channels,PriorityChannels,ForceChannel,SingleQuery,Template,Elements[JE_Example: Lead],LastNews[JE_Article: Lead, Galeria [JE_Gallery: Title,Banner [JE_Banner: Title],],],]", "Regex expression")

2º Result:

JE_Boxes
Identifier
Box
Namespace
Title
Channels
PriorityChannels
ForceChannel
SingleQuery
Template
Elements[JE_Example: Lead]
LastNews[JE_Article: Lead, Galeria [JE_Gallery: Title,Banner [JE_Banner: Title],],]

3º [Step] Call function:

Regex.Split("Elements[JE_Example: Lead]", "Regex expression")
Regex.Split("LastNews[JE_Article: Lead, Galeria [JE_Gallery: Title,Banner [JE_Banner: Title],],]", "Regex expression")

3º Result:

JE_Example
Lead

AND

JE_Article
Lead
Galeria [JE_Gallery: Title,Banner [JE_Banner: Title],]

4º [Step] Call function:

Regex.Split("Galeria [JE_Gallery: Title,Banner [JE_Banner: Title],]", "Regex expression")

4º Result:

JE_Gallery
Title
Banner [JE_Banner: Title]

5º [Step] Call function:

Regex.Split("Banner [JE_Banner: Title]", "Regex expression")

5º Result:

JE_Banner
Title

Obvious when i know the regular(s) expression(s) i will make this in a recursive method... Sorry for my long text, but this is the best way to present my problem...

1
  • 2
    that's a lot of details, but I'm afraid I can't find what the question is. could you clarify? Commented May 20, 2011 at 11:17

1 Answer 1

1

I think that in this case it might actually be easier to write a parser than a regular expression. You could use Irony, which is an excellent and easy to use library.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this was my "Did you know?" moment of the day :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.