i’m trying to wrap my head around this and all the examples on google and stackoverflow aren’t helping me understand.
i have this string
{{@test: mytest}}
{{@test mytest}}
I want to capture test and mytest from both those examples. so if that occurs in my string both will return the same array sets.
this is what i have/am trying to so far
/{{\s*@\s*(.*)\s*:\s*(.*)\s*}}/
this will work on the first example but will not on the second one.
so i thought maybe the answer would be to search trough the string skipping the :?
You haven’t clearly defined your criteria, but assuming that the texts you want to match may not contain whitespace, you can use this:
[^:\s]*matches a string that contains neither colons nor whitespace[^}\s]*matches a string that contains neither closing braces nor whitespace:?matches an optional colon