-4

Example input:

Ala ma kota (ASD defect - 7) kot ma ale.

Ideal output:

(ASD defect - 7)

How to parse this text from parentheses?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563

1 Answers1

1

In Grok, you'd need the following regex with a named capture group:

\((?<name>[^()]*)\)

This will match a text inside parentheses excluding parentheses. To include them, just put them into the capturing group:

(?<name>\([^()]*\))

The negated character class [^()]* matches 0 or more characters other than ) and (.

UPDATE:

As for using nested capturing groups, here is an example:

(?<sth2>\bwid:\s*(?<wid>\d+))

enter image description here

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563