6 examples of 'python find all indexes of character in string' in Python

Every line of 'python find all indexes of character in string' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
25def find_indexes(string):
26 """ Find indexes of all N's in string """
27 return [i for i, s in enumerate(string) if s == 'N']
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

10def find_first_index_of(string, character_list):
11 for i, c in enumerate(string):
12 if c in character_list:
13 return i
26def find_indexes(search_line, string):
27 indexes = []
28 before = 0
29 while 1:
30 i = search_line.find(string, before)
31 if i == -1:
32 break
33 indexes.append(i)
34 before = i + len(string)
35 return indexes
15def re_rindex(regex, string):
16 n = len(string)
17 for (char, index) in zip(reversed(string), xrange(n, -1, -1)):
18 if re.search(regex, char):
19 return index
20 return -1
675def get_correct_pos(self):
676 "Start- & End-Liste der richtigen %-Operatoren"
677 return self.get_pos(self.correct_hit_pos)
165def _find_string_start(self, offset):
166 kind = self.code[offset]
167 try:
168 return self.code.rindex(kind, 0, offset)
169 except ValueError:
170 return 0

Related snippets