Combine two regexes

后端 未结 2 1968
孤独总比滥情好
孤独总比滥情好 2021-01-20 20:43

I have two regular expressions which are working perfectly fine when use independently.

First  : ^.+\\.((jpeg)|(gif)|(png))\\s*$ : search for .jpeg,gif or p         


        
2条回答
  •  执笔经年
    2021-01-20 21:01

    You have extra spaces around the | operator:

    Your original regex
    ^.+\.((jpeg)|(gif)|(png))\s*$ | ^.+(javax.faces.resource|rfRes).*
    ^.+\.((jpeg)|(gif)|(png))\s*$|^.+(javax.faces.resource|rfRes).*
    Fixed regex                  ^
                                 |
    

    Your solution will try to match "the end of the string and then a space," or "a space and then the beginning of the string." Remember, whitespace is significant in regexes.

提交回复
热议问题