I am developing C# MVC application. I got an account name and its code from one field from the view but I have to segregate them for storing them in database. I have used Regular Expression and successfully separated the code from rest of the string. But in the string part I can only get the string before the space or hyphen. My Regex is:
string numberPart = Regex.Match(s, @"\d+").Value;
string alphaPart = Regex.Match(s, @"[a-zA-Z]+\s+").Value;
d.code = numberPart;
d.name = alphaPart;
"2103010001 - SALES - PACKING SERV - MUTTON ( 1F )" this is my complete string from the view. When I used the above Regex for separating code and description, I get the following,
numberPart = 2103010001
alphaPart = SALES
What I want is:
numberPart = 2103010001
alphaPart = SALES - PACKING SERV - MUTTON ( 1F )
What would be the appropriate expression to do this?
Aucun commentaire:
Enregistrer un commentaire