Help me to create a regular expression for String pattern matching
-
Wednesday, August 08, 2012 6:07 AM
Hello All,
Could anybody help me to split or separate the below given string in a specified format?
String : "TextBox","DisplayFormatString",#,###,###,##0.000,"Mask",n,"MaskType",Numeric, "MinimumValue",0,"MaximumValue",9999999999
Format: "Editor","PropertyName1",propertyvalue1,"Propertyname2",propertyValue2..etc)
I want to split the above array into a string array
1. PropertyName always enclosed with " , but propertyvalues cannot be compulsory to come with " .
2.The number of properties should be dynamic, If a propertyName is there , then next value should be value of that property.
3. Editor value should be the first part of the string.
Is it possible to get splitted this string with the above criterias?
Regards
Salam
salampv.07
All Replies
-
Thursday, August 09, 2012 6:24 AMModerator
Hi Salampv,
Welcome to the MSDN Forum.
First of all, I suggest you cut the editor string. And the left string can be "PropertyName1",propertyvalue1,"Propertyname2",propertyValue2..etc
And then, this regular expression will help you to obtain the property and value group:
(.*?(?=,"|$))
here is the test result:
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked As Answer by Mike FengMicrosoft Contingent Staff, Moderator Thursday, August 16, 2012 9:34 AM
-
Thursday, August 09, 2012 7:12 AM
Hello Mike,
Thank you very much for your reply. How can i get this result into a C# string array?
I will be wondered if you mention the code line?,
Regards
Salam
salampv.07
-
Thursday, August 09, 2012 3:47 PMModerator
Hi Salampv,
There is no method/function to call.
You need to split the groups by the first comma, and the first part is property name and the second party is the value. And then you need to put them in an array manually.
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

