Question: I'm looking for a regex that starts with `--` and ends if:

* Another `--` is found (it must be included),
* Or end of line is found.

For a version with end of line it works with `--[^\n]*` or `--.*$` and for the one ending with `--` it works with `--[^\n]*--` but I can't manage to combine both so that if another `--` is found it does not take the rest of the line.

For example:

* `toto -- tata yoyo` will match `-- tata yoyo`
* `toto -- tata -- yoyo` will match `-- tata --`

Edit: according to @duDE comment, I tried with `--[^\n]*(--|.*)` but the `.*` seems to win against `--` since in second example result match is `-- tata -- yoyo`

Edit2: thanks to @guest I have the answer, and this is simply `--.*?(--|$)`

NB: by the way, I use <https://www.debuggex.com/> to test regex, that I find be a great tool, and, even if for example with `--[^\n]*(--|.*)` regex and `toto -- tata -- yoyo` it returns "Don't match", we can see `-- tata -- yoyo` part matches since highlighted.

Thanks

Answer: 
Depending on your regex flavor, you can use:

**Edit:** Matches, now, the two hyphens if exist.

```
--[^-\r\n]+(?:--|$)

```

[Demo & explanation](https://regex101.com/r/N0qk7F/4)
Maybe something like `^.*(\<|$)` (anything from start of line up to word start/end of line)...