KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to find the positions of all occurrences of a string in another string, case-insensitive. For example, given the string: I learned to play the Ukulele in Lebanon. and the search string le , I want to obtain the array: [2, 25, 27, 33] Both strings will be variables - i.e., I can't hard-code their values. I figured that this was an easy task for regular expressions, but after struggling for a while to find one that would work, I've had no luck. I found this example of how to accomplish this using .indexOf() , but surely there has to be a more concise way to do it?
Tags (comma-separated)
Save Edits
Cancel