Skip to content

Commit b416abe

Browse files
committed
fix: do not match numbers larger than
1 parent f293692 commit b416abe

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/__tests__/matchDecimals.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,11 @@ describe("matchDecimals", () => {
2626
expect(matches?.length).toBe(1);
2727
expect(matches?.[0][0]).toBe("1776");
2828
});
29+
30+
it("should not match numbers larger than 3999", () => {
31+
const matches1 = matchDecimals("3999 is less than 4000");
32+
expect(matches1?.length).toBe(1);
33+
const matches2 = matchDecimals("It's over 9000");
34+
expect(matches2?.length).toBe(0);
35+
});
2936
});

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ export const ROMANS = [
2222
export const ROMANS_RXP =
2323
/(?<![MDCLXVI])(?=[MDCLXVI])M{0,3}(?:C[MD]|D?C{0,3})(?:X[CL]|L?X{0,3})(?:I[XV]|V?I{0,3})[^ ]\b/g;
2424

25-
export const DECIMALS_RXP = /(\d+)\b/g;
25+
export const DECIMALS_RXP = /\b([1-3]?[0-9]?[0-9]?[0-9])\b/g;

0 commit comments

Comments
 (0)