fpoyavo
asked on
Find or REPLACE
hI Experts,
How do I find or replace first comma which is not within double quotes in my string ?
Example :
(BBBB , "CCCC, DDDD")
Thank you.
How do I find or replace first comma which is not within double quotes in my string ?
Example :
(BBBB , "CCCC, DDDD")
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
Example does not mean (BBBB , "CCCC, DDDD") that BBBB CCCC DDDD the only ones. There may be any number of characters...
any characters.
Few more examples :
(any number of characters and/or spaces , "any number of characters and/or spaces , any number of characters and/or spaces , any number of characters and/or spaces etc")
Thanks.
Example does not mean (BBBB , "CCCC, DDDD") that BBBB CCCC DDDD the only ones. There may be any number of characters...
any characters.
Few more examples :
(any number of characters and/or spaces , "any number of characters and/or spaces , any number of characters and/or spaces , any number of characters and/or spaces etc")
Thanks.
yes the code could do for and string
you can check it will what you want
the function will return -1 when you enter error string like ("abas,)
other times it will work well
you can check it will what you want
the function will return -1 when you enter error string like ("abas,)
other times it will work well
CheckString(stringToProces
private void CheckString(string s)
{
System.Diagnostics.Debug.W
int index = IndexOfFirstCommaNotWithin
System.Diagnostics.Debug.W
}
private static int IndexOfFirstCommaNotWithin
{
int indexOfComma = temp.IndexOf(',');
int indexOfFirstQuote = temp.IndexOf('"');
int indexOfSecondQuote = temp.IndexOf('"', indexOfFirstQuote+1);
if (indexOfComma < indexOfFirstQuote)
{
return index + indexOfComma;
}
else
{
index = index + indexOfSecondQuote+1;
return IndexOfFirstCommaNotWithin
}
}