One of my java methods returns a paragraph string. How can i verify if the string has an ellipsis (...) in it?
Asked
Active
Viewed 1,647 times
-2
-
Do you mean, for [exmaple](http://stackoverflow.com/a/3597688/230513), "Will the string be _rendered_ with an ellipsis when placed in some GUI component?" – trashgod Jan 17 '13 at 04:52
-
yes, and as said below, it worked with all. String.contains, String.indexof. I was trying three dots while searching for the ellipsis, but when replaced three dots with actual ellipsis, all below suggestions worked, thanks – Inperta Jan 17 '13 at 10:20
3 Answers
4
myString.contains ("...");
It's in the documentation.

A--C
- 36,351
- 10
- 106
- 92
-
@Imperta, then you might have a funny "ellipsis" in there or it doesn't contain it. A simple test (1 string, 1 output statement) does conclude that `.contains()` works. – A--C Jan 17 '13 at 03:37
-
@Andrew it seems it doesn't work for them, which, unless they have some odd formatting/not an ellipsis, should work (same with your answer, it's basically the same comparison). – A--C Jan 17 '13 at 03:40
-
I misread the "thanks" as "good, it now know the string doesn't contain an ellipsis". My bad. – Andrew Jan 17 '13 at 04:57
-
1it worked thanks, @Bohemian was right, i was using three dots instead of ellipsis while searching for it. – Inperta Jan 17 '13 at 10:24
1
If you mean the whacky "ellipsis character" (ASCII 133 …
three little dots in one character), simply code that character in a string used with the contains()
method.
s.contains("…") // Not s.contains("...") (ie not "dot dot dot")
Copy-paste the ellipsis character from this answer into your code if you have to.

Bohemian
- 412,405
- 93
- 575
- 722
-
it worked, you are true, i was searching for three dots. when replaced it with actual ellipsis, it works. – Inperta Jan 17 '13 at 10:23