Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down