D
D
Dmitry Posokhov2016-09-09 08:09:02
Java
Dmitry Posokhov, 2016-09-09 08:09:02

How to trim a string in Java?

Everything! I've decided everything!
The solution was simple... as always:

String[] tmp = jEditorPane2.getText().split("\\?", 2);
jEditorPane2.setText(tmp[0]);

Many thanks to everyone who helped!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Posokhov, 2016-09-09
@Dmitriy625

I decided everything myself. Fast and easy as it turns out:

String[] tmp = jEditorPane2.getText().split("\\?", 2);
jEditorPane2.setText(tmp[0]);

X
X-, 2016-09-09
NoNAME @XNoNAME

String str1 = "toster.ru?abrakadabra....";
String str2 = str1.split("\\?")[0];
System.out.println(str2); //toster.ru

D
Dmitry Alexandrov, 2016-09-09
@jamakasi666

Read what is in the exception and fix or handle this exception.

P
protven, 2016-09-09
@protven

Try
replacing this with
tmp.offsetByCodePoints(0, limit -1))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question