We have updated our Terms of Service, Code of Conduct, and Addendum.

Regex to Grab Key:Value

Not a question but rather something useful. I have data that is in key:value format, using key=value in the extract format did not work. I was able to extract every key and value with this one regex extract.

(?<_NAME_0>.*):\s(?<_VALUE_0>.*)

Best Answer

  • Jon Rust
    Jon Rust Posts: 475 mod
    Answer ✓

    Upgoat! Great find, and thanks for sharing. That trick comes in handy so often. Also, dont forget to hit the global flag on the regex to get more than one matching pair.

Answers

  • Jon Rust
    Jon Rust Posts: 475 mod
    Answer ✓

    Upgoat! Great find, and thanks for sharing. That trick comes in handy so often. Also, dont forget to hit the global flag on the regex to get more than one matching pair.

  • pie
    pie Posts: 22 ✭✭

    hey @ekalby , this is a great tip–in the future, go ahead and ask your question and then post a separate answer if you have it, that way we can mark it solved and you can get the cribloons for it!