php - Regex To Match Pattern Unless It Ends With A Specific String -


i'm having little trouble coming regex particular situation. have.

"#<call:(\d+)>(?:(?!\/mm).)+?(\s+)?(?=\<)#ims" 

i need match following example.

<call:5>anything < 

but don't want match this...

<call:5>anything/mm < 

that's working ok, problem won't match this...

<call:5>anything/mmm < 

i need regex match anything provided anything not end /mm. know it's going small i'm overlooking, point out i'm doing wrong please?

if 1 can assume call tag contents matched not contain

  • spaces after (allowed?) /mm string or
  • < characters (except @ end),

the following seems work:

<call:(\d+)>(?:(?!\/mm[\s<]).)+?(\s+)?(?=\<) 

edit:

i think corner cases can solved well, try instead:

<call:(\d+)>(?:(?!\/mm\s*?<).)+?(\s+)?(?=\<) 

Comments