diff --git a/src/custom-sort/matchers.ts b/src/custom-sort/matchers.ts index 0163a6a..52154c9 100644 --- a/src/custom-sort/matchers.ts +++ b/src/custom-sort/matchers.ts @@ -8,7 +8,7 @@ export const NumberRegexStr: string = ' *(\\d+)'; // Plain number export const CompoundNumberDotRegexStr: string = ' *(\\d+(?:\\.\\d+)*)'; // Compound number with dot as separator export const CompoundNumberDashRegexStr: string = ' *(\\d+(?:-\\d+)*)'; // Compound number with dash as separator -export const Date_dd_Mmm_yyyy_RegexStr: string = ' *[0-3]*[0-9]-{Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec}-\\d{4}'; // Date like 01-Jan-2020 +export const Date_dd_Mmm_yyyy_RegexStr: string = ' *[0-3]*[0-9]-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\\d{4}'; // Date like 01-Jan-2020 export const DOT_SEPARATOR = '.' export const DASH_SEPARATOR = '-' diff --git a/src/custom-sort/sorting-spec-processor.ts b/src/custom-sort/sorting-spec-processor.ts index d7298a5..537dcc1 100644 --- a/src/custom-sort/sorting-spec-processor.ts +++ b/src/custom-sort/sorting-spec-processor.ts @@ -498,7 +498,7 @@ const sortingSymbolToRegexpStr: { [key: string]: RegExpSpecStr } = { [Date_dd_Mmm_yyyy_RegexSymbol]: { // Intentionally retain character case regexpStr: Date_dd_Mmm_yyyy_RegexStr, normalizerFn: Date_dd_Mmm_yyyy_NormalizerFn, - advancedRegexType: AdvancedRegexType.RomanNumber + advancedRegexType: AdvancedRegexType.Date_dd_Mmm_yyyy } } diff --git a/src/test/unit/sorting-spec-processor.spec.ts b/src/test/unit/sorting-spec-processor.spec.ts index b68d0ee..81a80dc 100644 --- a/src/test/unit/sorting-spec-processor.spec.ts +++ b/src/test/unit/sorting-spec-processor.spec.ts @@ -4,7 +4,7 @@ import { CompoundDotNumberNormalizerFn, ConsumedFolderMatchingRegexp, consumeFolderByRegexpExpression, - convertPlainStringToRegex, + convertPlainStringToRegex, Date_dd_Mmm_yyyy_NormalizerFn, detectSortingSymbols, escapeRegexUnsafeCharacters, extractSortingSymbol, @@ -404,11 +404,17 @@ const expectedSortSpecsExampleSortingSymbols: { [key: string]: CustomSortSpec } regex: /^(\p{Letter}+)\. is for any modern language word$/iu, normalizerFn: IdentityNormalizerFn } + }, { + type: CustomSortGroupType.ExactName, + regexPrefix: { + regex: /^ *[0-3]*[0-9]-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{4} for the specific date format of 12\-Apr\-2024$/i, + normalizerFn: Date_dd_Mmm_yyyy_NormalizerFn + } }, { type: CustomSortGroupType.Outsiders }], targetFoldersPaths: ['mock-folder'], - outsidersGroupIdx: 7 + outsidersGroupIdx: 8 } } @@ -420,6 +426,7 @@ Plain syntax\\R+ ... works? And this kind of... \\D+plain syntax??? Here goes ASCII word \\a+ \\A+. is for any modern language word +\\[dd-Mmm-yyyy] for the specific date format of 12-Apr-2024 ` describe('SortingSpecProcessor', () => { @@ -3141,6 +3148,7 @@ describe('hasMoreThanOneSortingSymbol', () => { ['\\-r+', false], ['--\\-r+--\\-D+++', true], ['\\d+abcd\\d+efgh', true], ['\\R+abcd\\.R+efgh', true], + ['\\R+abcd\\[dd-Mmm-yyyy]', true], ['\\d+\\.D+\\-d+\\R+\\.r+\\-R+ \\d+', true] ])('should correctly detect in >%s< (%s) sorting regex symbols', (s: string, b: boolean) => { const result = hasMoreThanOneSortingSymbol(s)