Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional clause in match group pattern for regex pattern to trim String version #2017

Open
SomenteRafael opened this issue Dec 9, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@SomenteRafael
Copy link

SomenteRafael commented Dec 9, 2024

PROBLEM is I have e.g.

  • "Version String" = ["1_0-release", "1_1_3", "1_2_0_0-release", "1_2_1", "1_2_1_1-release"]
    and want to sanitize it to
  • ["1.0", "1.1.3", "1.2.0.0", "1.2.1", "1.2.1.1"].

BY NOW I could clean 3-segmented-only versions with

  • "Trim String Version With RegEx" = "(\d+)(\d+)(\d+)" and
  • "Match Group to use for..." = "$1.$2.$3"

I could use

  • "Trim String Version With RegEx" = "(\d+)(\d+)?(\d+)?_?(\d+)?" and
  • "Match Group to use for..." = "$1.$2.$3.$4"
    and that applied to my list, i i'm right, that would result in matching
  • versions = ["1.0..", "1.2.3.", "1.2.0.0", "1.2.1.", "1.2.1.1"]
    so by now the I think it's the best result i'm gonna reach without the feature I want, which is a way to use a conditional clause in the match group pattern field, currently with simple variable substitution (specifically, to me, i need to include or not a dot if a group is not(empty or unnuded) so, used.

THE SYNTAX could be, for my purpose...:
$1.$(.)2$(.)3$(.)4

I don't know if regex excludes )( chars to be used in named patterns but anyways, not a problem anyways...

@SomenteRafael SomenteRafael added enhancement New feature or request to check Issue has not been reviewed labels Dec 9, 2024
@SomenteRafael SomenteRafael changed the title Conditional classe in match group pattern for regex pattern to trim String version Conditional clouse in match group pattern for regex pattern to trim String version Dec 9, 2024
@SomenteRafael SomenteRafael changed the title Conditional clouse in match group pattern for regex pattern to trim String version Conditional clause in match group pattern for regex pattern to trim String version Dec 9, 2024
@ImranR98 ImranR98 removed the to check Issue has not been reviewed label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants