diff --git a/dist/words-n-numbers.js b/dist/words-n-numbers.js index d3919cd..3bd828e 100644 --- a/dist/words-n-numbers.js +++ b/dist/words-n-numbers.js @@ -1 +1 @@ -var wnn;(()=>{var e={};(()=>{var r=e;const o="\\p{Alpha}+",s={regex:o,toLowercase:!1};r.extract=function(e,r){!0===(r={...s,...r}).toLowercase&&(e=e.toLowerCase());const o=new RegExp(r.regex,"giu");let a=[];return a=e.match(o),a},r.words=o,r.numbers="\\p{Number}+",r.emojis="\\p{Emoji_Presentation}+",r.wordsNumbers="\\p{Alpha}+|\\p{Number}+",r.wordsEmojis="\\p{Alpha}+|\\p{Emoji_Presentation}+",r.numbersEmojis="\\p{Number}+|\\p{Emoji_Presentation}+",r.wordsNumbersEmojis="\\p{Alpha}+|\\p{Number}+|\\p{Emoji_Presentation}+",r.tags="\\B[#][\\p{Alpha}|\\p{Number}]+",r.usernames="\\B[@][\\p{Alpha}|\\p{Number}]+",r.email="[0-9a-zA-Z!#$%&'*+-/=?^_`{|}~.]+@[0-9a-zA-Z-.]+"})(),wnn=e})(); \ No newline at end of file +var wnn;(()=>{var e={};(()=>{var r=e;const o="\\p{Alpha}+",a={regex:o,toLowercase:!1};r.extract=function(e,r){!0===(r={...a,...r}).toLowercase&&(e=e.toLowerCase());const o=new RegExp(r.regex,"giu");let s=[];return s=e.match(o),s},r.words=o,r.numbers="\\p{Number}+",r.emojis="\\p{Emoji_Presentation}+",r.wordsNumbers="\\p{Alpha}+|\\p{Number}+",r.wordsEmojis="\\p{Alpha}+|\\p{Emoji_Presentation}+",r.numbersEmojis="\\p{Number}+|\\p{Emoji_Presentation}+",r.wordsNumbersEmojis="\\p{Alpha}+|\\p{Number}+|\\p{Emoji_Presentation}+",r.tags="\\B[#][\\p{Alpha}|\\p{Number}]+",r.usernames="\\B[@][\\p{Alpha}|\\p{Number}]+",r.email="[0-9a-zA-Z!#$%&'*+-/=?^_`{|}~.]+@[0-9a-zA-Z-.]+[a-zA-Z0-9]"})(),wnn=e})(); \ No newline at end of file diff --git a/dist/words-n-numbers.js.map b/dist/words-n-numbers.js.map index 02e159e..5ac7022 100644 --- a/dist/words-n-numbers.js.map +++ b/dist/words-n-numbers.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://wnn/./index.js"],"names":["words","defaultOptions","regex","toLowercase","exports","extract","string","options","toLowerCase","RegExp","wordsNumbersEmojis","match","numbers","emojis","wordsNumbers","wordsEmojis","numbersEmojis","tags","usernames","email"],"mappings":"qCACA,MAAMA,EAAQ,cAoBRC,EAAiB,CACrBC,MAAOF,EACPG,aAAa,GAGfC,EAAQC,QAAU,SAAUC,EAAQC,IAQN,KAN5BA,EAAU,IACLN,KACAM,IAIOJ,cACVG,EAASA,EAAOE,eAIlB,MAAMN,EAAQ,IAAIO,OAAOF,EAAQL,MAAO,OAGxC,IAAIQ,EAAqB,GAEzB,OADAA,EAAqBJ,EAAOK,MAAMT,GAC3BQ,GAGTN,EAAQJ,MAAQA,EAChBI,EAAQQ,QA5CQ,eA6ChBR,EAAQS,OA1CO,2BA2CfT,EAAQU,aAxCa,2BAyCrBV,EAAQW,YAxCY,uCAyCpBX,EAAQY,cAxCc,wCAyCtBZ,EAAQM,mBAxCmB,oDAyC3BN,EAAQa,KAtCK,kCAuCbb,EAAQc,UAtCU,kCAuClBd,EAAQe,MAtCM,mD","file":"words-n-numbers.js","sourcesContent":["// Default. Only words. All languages\nconst words = '\\\\p{Alpha}+'\n\n// Only numbers, needs some work for real life numbers\nconst numbers = '\\\\p{Number}+'\n\n// Only emojis\nconst emojis = '\\\\p{Emoji_Presentation}+'\n\n// Words and numbers, Words and Emojis, Numbers and Emojis. Words and Numbers and Emojis. All lanugages.\nconst wordsNumbers = '\\\\p{Alpha}+|\\\\p{Number}+'\nconst wordsEmojis = '\\\\p{Alpha}+|\\\\p{Emoji_Presentation}+'\nconst numbersEmojis = '\\\\p{Number}+|\\\\p{Emoji_Presentation}+'\nconst wordsNumbersEmojis = '\\\\p{Alpha}+|\\\\p{Number}+|\\\\p{Emoji_Presentation}+'\n\n// #tags, @usernames or email.addresses@example.com\nconst tags = '\\\\B[#][\\\\p{Alpha}|\\\\p{Number}]+'\nconst usernames = '\\\\B[@][\\\\p{Alpha}|\\\\p{Number}]+'\nconst email = '[0-9a-zA-Z!#$%&\\'*+-/=?^_`{|}~.]+@[0-9a-zA-Z-.]+'\n\n// Default options object\nconst defaultOptions = {\n regex: words,\n toLowercase: false\n}\n\nexports.extract = function (string, options) {\n // Populate regex and options objects\n options = {\n ...defaultOptions,\n ...options\n }\n\n // string to lowercase ?\n if (options.toLowercase === true) {\n string = string.toLowerCase()\n }\n\n // regex constructor\n const regex = new RegExp(options.regex, 'giu')\n\n // match words (and numbers and emojis)\n let wordsNumbersEmojis = []\n wordsNumbersEmojis = string.match(regex)\n return wordsNumbersEmojis\n}\n\nexports.words = words\nexports.numbers = numbers\nexports.emojis = emojis\nexports.wordsNumbers = wordsNumbers\nexports.wordsEmojis = wordsEmojis\nexports.numbersEmojis = numbersEmojis\nexports.wordsNumbersEmojis = wordsNumbersEmojis\nexports.tags = tags\nexports.usernames = usernames\nexports.email = email\n"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack://wnn/./index.js"],"names":["words","defaultOptions","regex","toLowercase","exports","extract","string","options","toLowerCase","RegExp","wordsNumbersEmojis","match","numbers","emojis","wordsNumbers","wordsEmojis","numbersEmojis","tags","usernames","email"],"mappings":"qCACA,MAAMA,EAAQ,cAoBRC,EAAiB,CACrBC,MAAOF,EACPG,aAAa,GAGfC,EAAQC,QAAU,SAAUC,EAAQC,IAQN,KAN5BA,EAAU,IACLN,KACAM,IAIOJ,cACVG,EAASA,EAAOE,eAIlB,MAAMN,EAAQ,IAAIO,OAAOF,EAAQL,MAAO,OAGxC,IAAIQ,EAAqB,GAEzB,OADAA,EAAqBJ,EAAOK,MAAMT,GAC3BQ,GAGTN,EAAQJ,MAAQA,EAChBI,EAAQQ,QA5CQ,eA6ChBR,EAAQS,OA1CO,2BA2CfT,EAAQU,aAxCa,2BAyCrBV,EAAQW,YAxCY,uCAyCpBX,EAAQY,cAxCc,wCAyCtBZ,EAAQM,mBAxCmB,oDAyC3BN,EAAQa,KAtCK,kCAuCbb,EAAQc,UAtCU,kCAuClBd,EAAQe,MAtCM,8D","file":"words-n-numbers.js","sourcesContent":["// Default. Only words. All languages\nconst words = '\\\\p{Alpha}+'\n\n// Only numbers, needs some work for real life numbers\nconst numbers = '\\\\p{Number}+'\n\n// Only emojis\nconst emojis = '\\\\p{Emoji_Presentation}+'\n\n// Words and numbers, Words and Emojis, Numbers and Emojis. Words and Numbers and Emojis. All lanugages.\nconst wordsNumbers = '\\\\p{Alpha}+|\\\\p{Number}+'\nconst wordsEmojis = '\\\\p{Alpha}+|\\\\p{Emoji_Presentation}+'\nconst numbersEmojis = '\\\\p{Number}+|\\\\p{Emoji_Presentation}+'\nconst wordsNumbersEmojis = '\\\\p{Alpha}+|\\\\p{Number}+|\\\\p{Emoji_Presentation}+'\n\n// #tags, @usernames or email.addresses@example.com\nconst tags = '\\\\B[#][\\\\p{Alpha}|\\\\p{Number}]+'\nconst usernames = '\\\\B[@][\\\\p{Alpha}|\\\\p{Number}]+'\nconst email = '[0-9a-zA-Z!#$%&\\'*+-/=?^_`{|}~.]+@[0-9a-zA-Z-.]+[a-zA-Z0-9]'\n\n// Default options object\nconst defaultOptions = {\n regex: words,\n toLowercase: false\n}\n\nexports.extract = function (string, options) {\n // Populate regex and options objects\n options = {\n ...defaultOptions,\n ...options\n }\n\n // string to lowercase ?\n if (options.toLowercase === true) {\n string = string.toLowerCase()\n }\n\n // regex constructor\n const regex = new RegExp(options.regex, 'giu')\n\n // match words (and numbers and emojis)\n let wordsNumbersEmojis = []\n wordsNumbersEmojis = string.match(regex)\n return wordsNumbersEmojis\n}\n\nexports.words = words\nexports.numbers = numbers\nexports.emojis = emojis\nexports.wordsNumbers = wordsNumbers\nexports.wordsEmojis = wordsEmojis\nexports.numbersEmojis = numbersEmojis\nexports.wordsNumbersEmojis = wordsNumbersEmojis\nexports.tags = tags\nexports.usernames = usernames\nexports.email = email\n"],"sourceRoot":""} \ No newline at end of file diff --git a/index.js b/index.js index 2db24f3..5950560 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,7 @@ const wordsNumbersEmojis = '\\p{Alpha}+|\\p{Number}+|\\p{Emoji_Presentation}+' // #tags, @usernames or email.addresses@example.com const tags = '\\B[#][\\p{Alpha}|\\p{Number}]+' const usernames = '\\B[@][\\p{Alpha}|\\p{Number}]+' -const email = '[0-9a-zA-Z!#$%&\'*+-/=?^_`{|}~.]+@[0-9a-zA-Z-.]+[a-zA-Z]' +const email = '[0-9a-zA-Z!#$%&\'*+-/=?^_`{|}~.]+@[0-9a-zA-Z-.]+[a-zA-Z0-9]' // Default options object const defaultOptions = {