-1

So I've got this string:

for THING(taskname='packagedata', recipe='abba dancing queen'): {'taskid': '1', 'name': 'dumbledore', 'taskhash': 'e9a4bd7d06c7605338d1c29d85'} a b c d e f g build [[$class:StringParameterValue, name:PLATFORM, value:gold], [$class:StringParameterValue, name:DO_REBASE, value:TRUE], [$class:StringParameterValue, name:lincolnlogs, value:TRUE], [$class:StringParameterValue, name:BUILD_REUSE_TIMEOUT, value:TRUE], [$class:StringParameterValue, name:BUILD_REUSE_AGE_LIMIT, value:]] so then [abdcefs[0m[Pipeline] sh

I need to pull out the bits within recursive brackets.

  • (taskname='packagedata', recipe='abba dancing queen')
  • {'taskid': '1', 'name': 'dumbledore', 'taskhash': 'e9a4bd7d06c7605338d1c29d85'}
  • [[$class:StringParameterValue, name:PLATFORM, value:gold], [$class:StringParameterValue, name:DO_REBASE, value:TRUE], [$class:StringParameterValue, name:lincolnlogs, value:TRUE], [$class:StringParameterValue, name:BUILD_REUSE_TIMEOUT, value:TRUE], [$class:StringParameterValue, name:BUILD_REUSE_AGE_LIMIT, value:]]
  • [Pipeline]

The other answers I've seen involve recursive (?R), but JavaScript doesn't allow for (?R).

  • I don't think you can do balanced brackets using regex like you'd like to. What you really need is a parser like the one's that parse computer code (or HTML or JSON) – ControlAltDel Aug 07 '23 at 18:20
  • If there is no arbitrary depth, e.g. for max 3 depth like [this regex101 demo](https://regex101.com/r/uJGg5m/1). Deeper nesting needs to be added to the pattern (you can use the [depth generator in my answer here](https://stackoverflow.com/a/35271017/5527985)) (under the "Without recursion" section > Show code snippet) and adjust to multiple bracket types by attaching variations as alternations like I did in the regex101 demo. – bobble bubble Aug 07 '23 at 20:09

0 Answers0