Javascript regex to find words that do not start with "my:"
javascript, regex
Solution
This one should do:
/\{((?!my:)[^}]+)\}/g
Check quick demo http://jsbin.com/ujazul/2/edit
Problem
I'm trying to write a regex that will find all values between curly braces that do not begin with "my:". For example, I want to capture `{this}` but not `{my:monkey}`. The pattern that captures everything is: ``` \{([^\}]*)\} ``` I'm having trouble getting it to work. My closest shot so far is: ``` \{[^my:]*([^\}]*)\} ``` This fails because it only ignores tags beginning with "m", "y" or ":". I'm sure there is a command I'm overlooking to treat "my:" as a block.. (Note: Must work for Javascript)