window.setText(var.substring(var.indexOf("\""), var.indexOf("\"")));
How do I print text from a string in quotes, for example:
text text "quotes" text
and output: quotes
window.setText(var.substring(var.indexOf("\""), var.indexOf("\"")));
How do I print text from a string in quotes, for example:
text text "quotes" text
and output: quotes
To replace all double quotes with an empty string, you can use the String.replaceAll()
method:
window.setText(var.replaceAll("\"", ""));
Call:
System.out.println("\"Кавычки\"".replaceAll("\"", ""));
Will return:
Quotes
Text in quotes can be displayed as:
System.out.println("'Z'");
'Z'
That is, ("here quotes themselves (") ")).
You can use the indexOf
method.
for example
import java.util.*; import java.lang.*; import java.io.*; class Ideone { public static void main (String[] args) throws java.lang.Exception { String var = "текст текст \"кавычки\" текст"; int start = var.indexOf( '\"' ) + 1, end = var.indexOf( '\"', start ); System.out.println( var.substring( start, end ) ); } }
The output of the program to the console:
кавычки
Source: https://ru.stackoverflow.com/questions/964225/
All Articles