-
August 30th, 2011, 04:24 PM
#1
help with reg expression
What expression do I need to replace the second parameter in a string:
string(blah1,blah2,blah3)
to
string(blah1,"blah2",blah3)
basically it has to replace the text after the first comma but before the second comma but also it could be string(blah1,blah2) to not necessarily the second comma.
-
August 30th, 2011, 05:45 PM
#2
Re: help with reg expression
You could try...
Code:
string result = workingString.Replace(workingString.Split(',')[1], String.Format("\"{0}\"", workingString.Split(',')[1]));
...or the more verbose...
Code:
string result = string.Empty;
string[] stringParts = workingString.Split(',');
if (stringParts.Length > 1)
{
stringParts[1] = String.Format("\"{0}\"", stringParts[1]);
result = String.Join(",", stringParts);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|