Question: I want to match and expression that contains the string `yes`, but only if it's not preceded by the string `no`.

For example, this with match:
`Hello world, major yes here!`  

But this will not match: `Hell no yes`

The second string does not match because the `yes` string is preceded by `no` string. Apparently this needs negated lookbehind, which is not implemented in JavaScript regex flavor, I've tried stuff like that:
`/((?!no ))yes/`  

`/^(?!.*no) yes$/`

but they don't seem to have the desired effect :/

Answer: 
You could try the below regex.

```
^(?=(?:(?!\bno\b).)*yes).*

```

[DEMO](http://regex101.com/r/cM7fZ6/1)

**Explanation:**

```
^                        the beginning of the string
(?=                      look ahead to see if there is:
  (?:                      group, but do not capture (0 or more
                           times):
    (?!                      look ahead to see if there is not:
      \b                       the boundary between a word char
                               (\w) and something that is not a
                               word char
      no                       'no'
      \b                       the boundary between a word char
                               (\w) and something that is not a
                               word char
    )                        end of look-ahead
    .                        any character except \n
  )*                       end of grouping
  yes                      'yes'
)                        end of look-ahead
.*                       any character except \n (0 or more times)

```
This should work for you:

```
var reg = /^((?!no).)*yes.*$/

console.log("Test some no and yes".match(reg))
console.log("Test some yes".match(reg))
console.log("Test some yes and no".match(reg))

```

Just note that it wont work in sentences where there is no "yes" word like this:

```
console.log("Test some without".match(reg))

```

---

Here is reference that might help more about problem:

[Regular expression to match string not containing a word?](https://stackoverflow.com/a/406408)