I have a very large String. It can be seen here:
http://pastebin.com/vqXJ3WV6
I want to split this string using the regex 3.8
When I search this string using notepad, I find two instances of 3.8.
Therefore, I would expect the array which is returned to have a length of 3.
System.err.println(convertPdfToText(save).split("3.8").length);
However, calling this with convertPdfToText fetching this String has a length of 4?

I do not understand this at all in the slightest. Can anybody tell me what is going on because this is changing the behaviour of my program massively.
Thanks in advance
The
.character is a special character in regex which literally means “any character”. So you’re basically looking for3[anything]8, and a quick regex search shows that there is indeed 3 matches for that. Two are the valid “3.8” strings you were actually looking for. Your unintended match is located at the end of this string:The solution is simply to use the
.literal instead by escaping the character with backslashes: