Regular Expression Wildcard Matching

前端 未结 9 1476
甜味超标
甜味超标 2020-12-15 04:13

I have a list of about 120 thousand english words (basically every word in the language).

I need a regular expression that would allow searching through these words

9条回答
  •  萌比男神i
    2020-12-15 04:54

    1. Replace all '?' characters with '\w'
    2. Replace all '*' characters with '\w*'

    The '*' operator repeats the previous item '.' (any character) 0 or more times.

    This assumes that none of the words contain '.', '*', and '?'.

    This is a good reference

    http://www.regular-expressions.info/reference.html

提交回复
热议问题