About 26,500 results
Open links in new tab
  1. java - Find the Number of Occurrences of a Substring in a String ...

    You can find the number of occurrences of a substring in a string using Java 9 method Matcher.results() with a single line of code. It produces a Stream of MatchResult objects which …

  2. Java String lastIndexOf () Method with Examples - GeeksforGeeks

    Nov 19, 2024 · The String lastIndexOf() method returns the position of the last occurrence of a given character or substring in a String. The Index starts from 0, and if the given substring is …

  3. Java String lastIndexOf() Method - W3Schools

    The lastIndexOf() method returns the position of the last occurrence of specified character(s) in a string. Tip: Use the indexOf method to return the position of the first occurrence of specified …

  4. java - Last substring of string - Stack Overflow

    May 4, 2010 · public static String substringAfterLast(String str, String separator) Gets the substring after the last occurrence of a separator. The separator is not returned. A null string …

  5. java - How to find nth occurrence of character in a string?

    Oct 20, 2010 · You can also find the last nth occurrence of a character in a string with the lastOrdinalIndexOf method.

  6. Java Program to find the Last Index of a Particular Word in a String

    Aug 2, 2022 · To find out the last occurrence of a character or string from a given string across which the substring or character is been searched over and returning the index value of the …

  7. Java String lastIndexOf() Method with example - BeginnersBook

    Sep 11, 2022 · int lastIndexOf(String str): Returns the last occurrence of substring str in a String. int lastIndexOf(String str, int fromIndex) : Returns the last occurrence of str, starts searching …

  8. Java String lastIndexOf () - Find Last Index | Vultr Docs

    Dec 18, 2024 · Use the lastIndexOf(String str) method. In this instance, lastIndexOf() finds the last occurrence of the substring "the", returning 31. This method is case-sensitive which is why it …

  9. Find occurrences of a substring in a string in Java

    Mar 27, 2024 · The idea is to use the indexOf() method of the String class, which returns the index within this string of the first occurrence of the specified substring, starting at the specified …

  10. Find the Substring After the Last Pattern in Java | Baeldung

    Jul 27, 2024 · If we can find the last index of the pattern in the input String, we can extract the result using substring(): inputString.substring(lastIndexOfThePattern + pattern.length()) The …

  11. Some results have been removed
Refresh