user3186216 user3186216 - 22 days ago 10
ASP.NET (C#) Question

ASP.Net Regex Replace Pattern

Im new on the ASP.Net. I am working on a cart function.

My cart in session.

0001|1,0002|1

productid|quantity,productid|quantity,


How i can use Regex Replace and replace only quantity;

Example; 0001|1 --- > 0001|3 (It will 3 quantities)

Thanks and sorry little english.

Answer

I don't really know what you need, but if the quantity is between the two | you can use this code :

(?<=\|)(.*?)(?=\|)

http://imgur.com/a/Wb7s7

If quantity is between the | and the , use this:

(?<=\|)(.*?)(?=\,)

http://imgur.com/a/Ci7pb