Login
You're viewing the techdon.dev public feed.
  • Oct 13, 2026, 1:36 AM

    #regex question

    how do I capture a pattern as long as it does not catch another pattern

    In other words, how do I not capture the rows that are dashes here

    Regex101 page showing

regular expression: r”^\|(?P<key>[^\n]*?)\|(?P<value>[^\n]*?)\|$”

Input: 

# Changelog

This is the changelog for my cool mod!

| modName | MyCoolMod     |
| ------- | ------------- |
| license | CC-By-SA      |
| website | Example.com   |
| author  | A cool person |

## 1.0.0 - 2020-04-16 [KSP 1.11]

First full release
    💬 1🔄 0⭐ 0

Replies

  • 💬 0🔄 0⭐ 0
  • Oct 13, 2026, 6:17 AM

    @cinebox Honestly, unless you're using one of the "fancier" (actually more regular) engines that can do regex intersection and negation, it's probably more readable to parse the general structure first and filter out dash lines in a separate pass. Cramming it all into a single regex with negative look-ahead and the like quickly gets unreadable (unless you use something like Perl that allows sane formatting/indentation/comments within regexes, but I'd still do two passes there).

    💬 0🔄 0⭐ 0