c# - StringSplitOptions.None doesn't work as expected -
i'm trying convert string string[] using 2 delimiters , want delimiters null strings in resultant string[] nodes
string source = "(('co.in'.bit = c) or ('co.in'.bit = v))"; char[] delimiters = new char[] { '(', ')' }; string[] parts = source.split(delimiters,stringsplitoptions.none); the expected result string[] parts is:
[null] [null] 'co.in'.bit = c [null] ' or ' [null] 'co.in'.bit = v [null] [null] but result obtained is:
[null] [null] 'co.in'.bit = c ' or ' 'co.in'.bit = v [null] [null] i miss 2 nodes , don't understand why.
can me please?
your assumption null values delimiters wrong. empty string if there no text between 2 delimiters.
the first 2 empty strings ([null] in post) appear because there no text between start of string , first delimiter , no text between first , second delimiter.
but c) or ('co (part of string) can split c, or , 'co without empty string between 2 delimiters.
Comments
Post a Comment