Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# get all occurrences of a string

public List<Integer> findWordUpgrade(String textString, String word) {
    List<Integer> indexes = new ArrayList<Integer>();
    StringBuilder output = new StringBuilder();
    String lowerCaseTextString = textString.toLowerCase();
    String lowerCaseWord = word.toLowerCase();
    int wordLength = 0;

    int index = 0;
    while(index != -1){
        index = lowerCaseTextString.indexOf(lowerCaseWord, index + wordLength);  // Slight improvement
        if (index != -1) {
            indexes.add(index);
        }
        wordLength = word.length();
    }
    return indexes;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# switch expression pattern matching 
Csharp :: method c# 
Csharp :: C# Change color 
Csharp :: select top 5 in linq c# 
Csharp :: run in wpf 
Csharp :: select from list where not in other list c# 
Csharp :: gql query with parameters 
Csharp :: how to get params our of url c# VB 
Csharp :: c sharp async 
Csharp :: c# switch when 
Csharp :: c# datediff 
Csharp :: hide external app from taskbar 
Csharp :: messagebox yes no c# 
Csharp :: c# getting response content from post 
Csharp :: c# how to get a securestring from string 
Csharp :: matrix transpose 
Csharp :: truncate c# 
Csharp :: lightbox 
Csharp :: overridable method C# 
Csharp :: concurrent post request c# 
Csharp :: Moq Unittest with ILogger 
Csharp :: unity android keycodes 
Csharp :: c# on alt + f4 
Csharp :: c# fold sum array 
Csharp :: messagebox error c# 
Csharp :: how to get angular on visual studio mac 
Csharp :: psobject get service name 
Csharp :: 2d collision handling jump table 
Csharp :: tomatch jest 
Csharp :: epplus how to align text to right 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =