You can use the following regular expression pattern in TypeScript to find words that end in "lex" in a given string:
index.ts260 chars8 lines
Here, \b
represents a word boundary and \w
represents a word character. The *
ensures that any number of characters can come before "lex". The g
flag is used to find all matches in the string.
This code will output ["reflex", "complex", "perplex"]
in the console.
gistlibby LogSnag