I have a statement string like this:
*
| { table_name | view_name | table_alias }.*
| {
[ { table_name | view_name | table_alias }. ]
{ column_name | $IDENTITY | $ROWGUID }
| udt_column_name [ { . | :: } { { property_name | field_name } | method_name ( argument [ ,...n] ) } ]
| expression
[ [ AS ] column_alias ]
}
| column_alias = expression
I need only the outermost items,so I use char |
to split the content, I want to exclude any the |
exist in brackets.
The result of the split is that it has 4 items, like this:
#1 *
#2 { table_name | view_name | table_alias }.*
#3 {
[ { table_name | view_name | table_alias }. ]
{ column_name | $IDENTITY | $ROWGUID }
| udt_column_name [ { . | :: } { { property_name | field_name } | method_name ( argument [ ,...n] ) } ]
| expression
[ [ AS ] column_alias ]
}
#4 column_alias = expression
I tried some like (?m)\s*^\|\s*
or ^(({\|\s*})({\{})?)({.+})$
but that just get me ONE item not FOUR items.
Thanks for @Wiktor Stribiżew and @Rui Jarimba help.
I has idea (?<!\{[^\}]*)\|(?![^\{]*\})
and I get like this:
#1 *
#2 { table_name | view_name | table_alias }.*
#3
{
[ { table_name | view_name | table_alias }. ]
{ column_name | $IDENTITY | $ROWGUID }
#4
udt_column_name [ { . | :: } { { property_name | field_name } | method_name ( argument [ ,...n] ) } ]
| expression
[ [ AS ] column_alias ]
}
#5 column_alias = expression
Now, I need some change to fix (?<!\{[^\}]*)\|(?![^\{]*\})
and clear #4 ....
okey, I Find a pattern, may be it is not perfect but it is work. it like this:
Regex.Split(s, @"(?<!\{(?>[^\{\}]+|\{(?<D>)|\}(?<-D>))*(?(D)(?!)))\|(?!(?>[^\{\}]+|\{(?<D>)|\}(?<-D>))*(?(D)(?!))\})")
Finally, I would like to thank all those who helped me again.