Quantcast
Channel: CodeProject Latest postings for Regular Expressions
Viewing all articles
Browse latest Browse all 224

Can anybody explain how this Regex works.

$
0
0
Hi
I'm using C# and I have the regex below to split words and not split a string ".. .." instead take the whole string as on item to a List.

Example:
text="all "1 dl""
after split
all[0]="all"
all[1]="1 dl"

I found it in Google and it works, but I don't understand how it works.

string regexSpliter = @"(?<=^(?:[^""]*""[^""]*"")*[^""]*) ";
List<string> all =new List<string>_ (System.Text.RegularExpressions.Regex.Split(text, regexSpliter));
 
And if I remove the space before the last " in the string it doesn't work as I want. It seems like it splits all the characters in to elements written in the string text.
 
Can anybody please explain the string regexSplitter and why it has to be a space last in the string.
 
Many thanks
Fia

Viewing all articles
Browse latest Browse all 224

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>