Conditional clause in match group pattern for regex pattern to trim String version
- Dominant language
- Dart
- Stars
- 19.8k
- Forks
- 599
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 54
Description
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...
Contributor guide
Research direction
Start by locating the implementation of the “Trim String Version With RegEx” and “Match Group to use for...” settings in Obtainium. Review how regex groups and replacement strings are currently handled, then define the conditional replacement syntax and expected behavior for missing groups, including the example version list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100