Match Numbers Between Brackets []

I am attempting to isolate the numbers that are in a description posted to a Webhook in n8n. The numbers are between square brackets and what I’m trying doesn’t work.

{{$json["body"]["project"]["name"].match(/\\[(.*?)\\]/)}}

String:

Ticket 1234 - Not So Clever Admin [8675309]

This should work:

{{ $json["body"]["project"]["name"].match(/\[(\d+)]/)[1] }}

Example workflow:

{
  "nodes": [
    {
      "parameters": {
        "functionCode": "items[0].json = {\n  body: {\n    project: {\n      name: 'Ticket 1234 - Not So Clever Admin [8675309]'\n    }\n  }\n};\nreturn items;"
      },
      "name": "Mock Data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "id",
              "value": "={{ $json[\"body\"][\"project\"][\"name\"].match(/\\[(\\d+)]/)[1] }}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    }
  ],
  "connections": {
    "Mock Data": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

That did work, thank you @jan.

Glad to hear. Have fun!