Question: Converting Bash Option String to Unix Environment Variable Name using vscode snippet Transformation

I am working on a bash script snippet for the sheller extension where I need to convert a Bash option string entered by the user into a valid Unix environment variable name. For example, the user may enter an option string like "-my-option-name" or "--another_option=", and I need to transform it into a valid environment variable name like "MY_OPTION_NAME" or "ANOTHER_OPTION".
To clarify my requirements and provide a clear understanding of the desired transformation, I have created a JavaScript example on JSFiddle. You can find it here. The example showcases a table of different input strings and their expected output after the transformation.
The javascript function handling the transformation used in the fiddle.
function stripCapitalizeAndSnake(inputString) {
  const regex = /^-+(.*?)(?:=)?$/;
  const result = inputString.replace(regex, (_, selectedString) => {
    const transformedString = selectedString.replace(/-/g, '_');
    return transformedString.toUpperCase();
  });
  return result;
}

I am seeking guidance or preferably code examples on how to implement this transformation using snippet transforms in Visual Studio Code snippets.

Thank you in advance for your assistance, especially if you have experience or knowledge about the vscode, code snippets and transformations!

Here is a simplified version of a snippet, which I hope someone can modify for the expected result.
Current snippet
{
    "OPTION TO ENVIRONMENT": {
        "prefix": "option to environment",
        "body": [
            "#!/usr/bin/env bash",
            "",
            "OPTION=\"${1:--quiet-mode}\"",
            "",
            "echo \"Option        :\\${OPTION}\"",
            "echo \"Variable name :${1/^(\\-+)([^=]+)(=)?$/${2:/upcase}/}\""
        ],
        "description": "Convert bash option to a valid shell environment variable"
    }
}

Current Result
When triggering the snippet, and leaving the default value as is the Variable name is correct except for the fact that "-" is not replaced with "_" which is my problem.
"QUIET-MODE" needs to be transformed to "QUIET_MODE".
#!/usr/bin/env bash

OPTION="--quiet-mode"

echo "Option        :${OPTION}"
echo "Variable name :QUIET-MODE"

I have been trying to do this for a while now, so I ask you, do you know how to do this?
Ps.
Do you know of a better documentation about transformations, other than is mentioned here?


Answer:
use the extension Hypersnips
you can add JavaScript to the snippet

It can be done with VSC standard snippets

capture possible starting - characters, ignore in result
capture all till - or =, UPCASE that group
capture possible -, substitute with _
capture possible =, ignore in result

apply these rules global/repeatedly
{
  "OPTION TO ENVIRONMENT": {
    "prefix": "option to environment",
    "body": [
        "#!/usr/bin/env bash",
        "",
        "OPTION=\"${1:--quiet-mode}\"",
        "",
        "echo \"Option        :\\${OPTION}\"",
        "echo \"Variable name :${1/(^-+)?([^-=]+)(-?)(=?)/${2:/upcase}${3:+_}/g}\""
    ],
    "description": "Convert bash option to a valid shell environment variable"
}