REGEX SPILT BASED ON MULTIPLE DELIMITERS IN C#

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
C# 
C#
 2655  View(s)
Ratings:
Rate this:
Hi Developers,

I have a string of type "KeyOperatorValue1,Value2,Value2....". For e.g = "version>=5", "lang=en,fr,es" etc and currently, 

the possible value for operator field is "=", "!=", ">", ">=", "<", "<=", but I don't want it to be limited to them only. 

Now the problem is given such a string, how can I split into a triplet?

Since, all the operator's string representation are not mutually exclusive("=" is a subset of ">="), I can't use public 

string[] Split(string[] separator, StringSplitOptions options) and the Regex.Split doesn't have a variant which takes 

multiple regex as parameters.

Thanks in advance. 

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Regex Spilt based on multiple delimiters in C#

    Hi Ankita,


    try as following line of code

    "(\w+)(=|!=|>(?!=)|>=|<(?!=)|<=)([^"]+)"

    I hope it helpful for you.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!