Regex to capture everything before first optional string

前端 未结 5 722
旧时难觅i
旧时难觅i 2020-12-16 02:20

I want to capture a pattern upto but not including the first instance of an optional other pattern with preg_match, eg:

ABCDEFGwTW$%                                  


        
5条回答
  •  别那么骄傲
    2020-12-16 03:01

    You can have the result with a lot less confusion:

    Just check a simpler version of the pattern to match, and if not, use the original string:

提交回复
热议问题