Share your repls and programming experiences

← Back to all posts
Crappy search thingy with back referencing in regex

This is a thing i made that will use back referencing in regex to search for a word in your input.

click 'Search'
type the word you would like to search for
type a colon
type the text that will be searched.

bob: hi my name is bob and i like cheese
This will search for the word bob in the rest of the text

How it works:
This is pretty self explanatory to anybody who knows regex the slightest bit but here is how it works.

The regex pattern that finds it is:
The ^ means the next thing has to start the string. Because the next thing is in parenthesis, it counts as one group. \w means any alphabetical character, and + means one or more. The : just means it will search for a colon. The . means any character, and the
means zero or more. \1 means the first group of characters in the pattern. That first group is whatever triggered (\w+). This means it is searching for your input.