git-prefix icon indicating copy to clipboard operation
git-prefix copied to clipboard

Regex match not extracting correct expression

Open dbersan opened this issue 1 year ago • 3 comments

I have a branch name like ABCD-1223

And the Pattern is set to: ^([A-Z]{3,5})-([0-9]{3,5})

When I run the Prefix commit message, the prefix is set to ABCD, even though:

image

dbersan avatar Apr 19 '24 08:04 dbersan

I'm having issues with this as well. When my branch is named hotfix/ABCD-1234-fix-this-or-that and my regex is set to (ABCD-\d+), it will enter this text:

hotfix/ABCD-1234: -fix-this-or-that

But it should be:

ABCD-1234: 

According to regexr, my regex is fine: image

My settings are: image

DaVince avatar Jul 18 '24 09:07 DaVince

hotfix/ABCD-1234-fix-this-or-that

Please enter this .*(ABCD-\d+).* as value for your Regex, then it will work

image

{
  "gitPrefix.pattern": ".*(ABCD-\\d+).*",
  "gitPrefix.replacement": "$1:"
}

PKief avatar Jul 22 '24 20:07 PKief

hotfix/ABCD-1234-fix-this-or-that

Please enter this .*(ABCD-\d+).* as value for your Regex, then it will work

image

{
  "gitPrefix.pattern": ".*(ABCD-\\d+).*",
  "gitPrefix.replacement": "$1:"
}

Thanks PKief, good workaround. I do still hope it gets fixed to work as expected so no one in the future has to be confused about this.

DaVince avatar Jul 27 '24 08:07 DaVince