Skip to content

Commit fa35e04

Browse files
committed
Don't add positional specifiers if the format specifier already has them
1 parent a475327 commit fa35e04

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Core/Source/NSString+DTLocalizableStringScanner.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ - (NSString *)stringByNumberingFormatPlaceholders
1515
static dispatch_once_t onceToken;
1616
static NSRegularExpression *matchNonEscapedPercent = nil;
1717
dispatch_once(&onceToken, ^{
18-
matchNonEscapedPercent = [NSRegularExpression regularExpressionWithPattern:@"(?<=[^%]|^)(?:(?:%%)*)(%)(?:[^%]|$)" options:0 error:NULL];
18+
matchNonEscapedPercent = [NSRegularExpression regularExpressionWithPattern:@"(?<=[^%]|^)(?:(?:%%)*)(%(?!\\d+\\$))(?:[^%]|$)" options:0 error:NULL];
1919
});
2020

2121
__block NSMutableString *tmpString = nil;

Test/Resources/Testcases.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ NSLocalizedString(@"%@ had been successfully added to the Address Book.\nWould y
99

1010
NSLocalizedString(@"foo " @"bar", @"Test multi-part quoted strings");
1111

12+
NSLocalizedString(@"Item %1$d of %2$d", @"Test positional params");
13+
1214
// some regular test cases
1315

1416

0 commit comments

Comments
 (0)