Java detect double double quotes in String
30,606
You are checking for 2 "(double quotes)s
while your string has only one in the beginning. Try below:
test.startsWith("\"");
test.endsWith("\"");
Should work.
Author by
JAB
Updated on July 09, 2022Comments
-
JAB almost 2 years
Sample Code
public static void main(String args[]){ String test=null; if(some condition) test = "\"abc\""; else test ="def"; // if condition is true , in debug mode when i check the value of test its ""abc"" (double double quote); // if condition is false , then value of test is "def" (double quotes only one time); }
Looking for a logic to check whether string has double double quotes . Tried below stuff
// test.startsWith("\"\"")) // this didn;t work
-
Shajeel Afzal over 7 yearsThanks, How to remove these?
-
Yogendra Singh over 7 yearsYou can use replaceAll method.