我在复杂字符串中遇到了一个特殊问题:
字符串模式:
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
树模式:
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.Split的目标是这样的:
1º[Step]调用功能:
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º结果:
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]调用功能:
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º结果:
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]调用功能:
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º结果:
JE_Example
Lead
和
JE_Article
Lead
Galeria [JE_Gallery: Title,Banner [JE_Banner: Title],]
4º[Step]调用功能:
Regex.Split("Galeria [JE_Gallery: Title,Banner [JE_Banner: Title],]", "Regex expression")
4º结果:
JE_Gallery
Title
Banner [JE_Banner: Title]
5º[Step]调用功能:
Regex.Split("Banner [JE_Banner: Title]", "Regex expression")
5º结果:
JE_Banner
Title
当我知道常规表达式时,我会用递归方法做出这个... 对不起我的长篇文章,但这是提出问题的最好方法......