Regex: This regex splits comma or semicolon separated lists of optionally quoted strings. It hand...

Posted by: RegexLib.com - Recent Patterns, on 25 Jan 2006 | View original | Bookmarked: 0 time(s)

Regex: This regex splits comma or semicolon separated lists of optionally quoted strings. It handles quoted delimiters and escaped quotes. Whitespace inside quotes is preserved, outside is eaten. I actually wrote this one over time myself, but it is so similar to Michael Ash's that I had to give credit. The only differences are the handling of whitespace and dual comma/semicolon delimiters.

*********************************************

\s*[;,]\s*(?!(?<=(?:^|[;,])\s*"(?:[^"]|""|\\")*[;,])(?:[^"]|""|\\")*"\s*(?:[;,]|$))

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: Regex | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 4330 | Hits: 58

Similar Posts

  • Asynchronous command execution in .NET 2.0 more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD