Regular expression to search multiple strings (Textpad)

前端 未结 3 558
挽巷
挽巷 2020-12-13 23:51

I\'m a bit new to regex and am looking to search for multiple lines/instaces of some wildcard strings such as *8768, *9875, *2353.

I would like to pull all instances

3条回答
  •  余生分开走
    2020-12-14 00:17

    To get the lines that contain the texts 8768, 9875 or 2353, use:

    ^.*(8768|9875|2353).*$
    

    What it means:

    ^                      from the beginning of the line
    .*                     get any character except \n (0 or more times)
    (8768|9875|2353)       if the line contains the string '8768' OR '9875' OR '2353'
    .*                     and get any character except \n (0 or more times)
    $                      until the end of the line
    

    If you do want the literal * char, you'd have to escape it:

    ^.*(\*8768|\*9875|\*2353).*$
    

提交回复
热议问题