Skip to content
Open
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
11 changes: 10 additions & 1 deletion lib/textMetadataAndExtraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ function extractNumbers(string) {
return matches ? matches.map(Number) : [];
}

// Extracts all emails from a text using regex pattern that finds all the vaalid emails from text and mas then into an array
function extractEmails(text) {
return (text.match(
/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi
) || []).map(email => email.toLowerCase());
}



// Counts the number of words in a string.
function countWords(string) {
// Input: 'Hello world, this is a test.'
Expand Down Expand Up @@ -165,4 +174,4 @@ function extractJSONStrings(string) {
}

// Grouped exports
export { extractNumbers, countWords, countCharacter, findPositions, extractHashtags, extractURLs, extractEmails, extractMentions, extractParenthesizedContent, extractQuotedText, extractHTMLTags, extractDates, extractPhoneNumbers, extractIPv4Addresses, extractIPv6Addresses, extractFilePaths, extractFilePaths, extractDomainNames, extractJSONStrings };
export { extractNumbers, extractEmails, countWords, countCharacter, findPositions, extractHashtags, extractURLs, extractEmails, extractMentions, extractParenthesizedContent, extractQuotedText, extractHTMLTags, extractDates, extractPhoneNumbers, extractIPv4Addresses, extractIPv6Addresses, extractFilePaths, extractFilePaths, extractDomainNames, extractJSONStrings };