Substring between characters in Salesforce using apex

Sample Code:

String str1 = 'Hello';
String str2 = str1.substringBetween('H', 'o');
System.debug(str2);

Output:

  • Arun

    What if we have multiple substring which follow the pattern

    for example String str = ‘Hello Heelllllo’;

    In this case I would like to get a List of Substrings which are in between the two characters. Is there a best efficient way to do that.