I have some Strings. They contain some data. Example: “Alberto Macano. Here is description.” And another example: “Pablo Don Carlo. Description here.”
What I need: A method to split The Name from description. e.g getting the name in one string, and the description in another string. It woudl be easier if id know how much words will name contain, but it can contatin up to 5-6 words, so idk how mcuh will it be. Exact thing that i know, that a punct splits them.
You can use the .split(String regex) method to split the string into an array of strings. So for instance:
The ‘words’ variable will contain the following:
{0}: Alberto Macano
{1}: Here is description
You might notice that there are two slashes before the period sign, this is because the period is a special keyword in regular expressions, so it has to be escaped by a slash. You might want to look at the Java Regex Documentation for more information.