diff --git a/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/extract-profile.ts b/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/extract-profile.ts index 8f558f2d..26e11ae3 100644 --- a/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/extract-profile.ts +++ b/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/extract-profile.ts @@ -25,7 +25,9 @@ const hasAt = (item: TextItem) => item.text.includes("@"); // Phone // Simple phone regex that matches (xxx)-xxx-xxxx where () and - are optional, - can also be space export const matchPhone = (item: TextItem) => - item.text.match(/\(?\d{3}\)?[\s-]?\d{3}[\s-]?\d{4}/); + item.text.match( + /(?:\+?\d{1,3}[-.\s]?)?(?:\(?\d{1,4}\)?[-.\s]?){1,4}\d{1,4}/ + ); const hasParenthesis = (item: TextItem) => /\([0-9]+\)/.test(item.text); // Location diff --git a/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/extract-resume-from-sections.test.ts b/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/extract-resume-from-sections.test.ts index 5dd90f0d..ec10aa6b 100644 --- a/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/extract-resume-from-sections.test.ts +++ b/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/extract-resume-from-sections.test.ts @@ -28,6 +28,10 @@ describe("extract-profile tests - ", () => { expect(matchPhone(makeTextItem(" (123)456-7890 "))![0]).toBe( "(123)456-7890" ); + expect(matchPhone(makeTextItem("+1 123-456-7890"))![0]).toBe("+1 123-456-7890"); + expect(matchPhone(makeTextItem("+44 20 7946 0958"))![0]).toBe("+44 20 7946 0958"); + expect(matchPhone(makeTextItem("+91-98765-43210"))![0]).toBe("+91-98765-43210"); + expect(matchPhone(makeTextItem("0049 30 123456"))![0]).toBe("0049 30 123456"); }); it("Url", () => {