Regex Issue for name

Anybody can help on this…

Have created regex for name entities. I am able to go to next node ,if i entered wrong name.Only want to take english aphabets.
ex… fd242 , दास
regax i have used as follow…please check screenshot.
[A-Za-z]+\s*[A-Za-z]{2,30}$




image

On regex site It’s working properly

Please add a function to wrap it better.

  1. Regex for hindi : /^[\u0900-\u097F. ]+$/u or /^[\u0900-\u097F. ]{2,30}$/u
  2. Regex for English : /^[a-zA-Z ]{2,30}$/gm
    Stop words exclusion for english:
const STOPWORDS_LONG = [
            'a', 'able', 'about', 'above', 'language', 'change', 'agent', 'branch',
            'abst', 'accordance', 'according', 'accordingly',
            'across', 'act', 'actually', 'added', 'end',
            'adj', 'affected', 'affecting', 'affects',
            'after', 'afterwards', 'again', 'against',
            'ah', 'all', 'almost', 'alone', 'feedback',
            'along', 'already', 'also', 'although',
            'always', 'am', 'among', 'amongst',
            'an', 'and', 'announce', 'another',
            'any', 'anybody', 'anyhow', 'anymore',
            'anyone', 'anything', 'anyway', 'anyways',
            'anywhere', 'apparently', 'approximately', 'are',
            'aren', 'arent', 'arise', 'around',
            'as', 'aside', 'ask', 'asking',
            'at', 'auth', 'available', 'away',
            'awfully', 'b', 'back', 'be',
            'became', 'because', 'become', 'becomes',
            'becoming', 'been', 'before', 'beforehand',
            'begin', 'beginning', 'beginnings', 'begins',
            'behind', 'being', 'believe', 'below',
            'beside', 'besides', 'between', 'beyond',
            'biol', 'both', 'brief', 'briefly',
            'but', 'by', 'c', 'ca',
            'came', 'can', 'cannot', "can't",
            'cause', 'causes', 'certain', 'certainly',
            'co', 'com', 'come', 'comes', 'contain',
            'containing', 'contains', 'could', 'couldnt', 'd',
            'date', 'did', "didn't", 'different', 'do',
            'does', "doesn't", 'doing', 'done', "don't",
            'down', 'downwards', 'due', 'during', 'e',
            'each', 'ed', 'edu', 'effect', 'eg',
            'eight', 'eighty', 'either', 'else', 'elsewhere',
            'end', 'ending', 'enough', 'especially', 'et',
            'et-al', 'etc', 'even', 'ever', 'every',
            'everybody', 'everyone', 'everything', 'everywhere', 'ex',
            'except', 'f', 'far', 'few', 'ff',
            'fifth', 'first', 'five', 'fix', 'followed',
            'following', 'follows', 'for', 'former', 'formerly',
            'forth', 'found', 'four', 'from', 'further',
            'furthermore', 'g', 'gave', 'get', 'gets',
            'getting', 'give', 'given', 'gives', 'giving',
            'go', 'goes', 'gone', 'got', 'gotten',
            'h', 'had', 'happens', 'hardly', 'has',
            "hasn't", 'have', "haven't", 'having', 'he',
            'hed', 'hence', 'her', 'here', 'hereafter',
            'hereby', 'herein', 'heres', 'hereupon', 'hers',
            'herself', 'hes', 'hi', 'hid', 'him',
            'himself', 'his', 'hither', 'home', 'how',
            'howbeit', 'however', 'hundred', 'i', 'id',
            'ie', 'if', "i'll", 'im', 'immediate',
            'immediately', 'importance', 'important', 'in', 'inc',
            'indeed', 'index', 'information', 'instead', 'into',
            'invention', 'inward', 'is', "isn't", 'it',
            'itd', "it'll", 'its', 'itself', "i've",
            'j', 'just', 'k', 'keep keeps', 'kept',
            'kg', 'km', 'know', 'known', 'knows',
            'l', 'largely', 'last', 'lately', 'later',
            'latter', 'latterly', 'least', 'less', 'lest',
            'let', 'lets', 'like', 'liked', 'likely',
            'line', 'little', "'ll", 'look', 'looking',
            'looks', 'ltd', 'm', 'made', 'mainly',
            'make', 'makes', 'many', 'may', 'maybe',
            'me', 'mean', 'means', 'meantime', 'meanwhile',
            'merely', 'mg', 'might', 'million', 'miss',
            'ml', 'more', 'moreover', 'most', 'mostly',
            'mr', 'mrs', 'much', 'mug',
            'must', 'my', 'myself', 'n',
            'na', 'name', 'namely', 'nay',
            'nd', 'near', 'nearly', 'necessarily',
            'necessary', 'need', 'needs', 'neither',
            'never', 'nevertheless', 'new', 'next',
            'nine', 'ninety', 'no', 'nobody',
            'non', 'none', 'nonetheless', 'noone',
            'nor', 'normally', 'nos', 'not',
            'noted', 'nothing', 'now', 'nowhere',
            'o', 'obtain', 'obtained', 'obviously',
            'of', 'off', 'often', 'oh',
            'ok', 'okay', 'old', 'omitted',
            'on', 'once', 'one', 'ones',
            'only', 'onto', 'or', 'ord',
            'other', 'others', 'otherwise', 'ought',
            'our', 'ours', 'ourselves', 'out',
            'outside', 'over', 'overall', 'owing',
            'own', 'p', 'page', 'pages',
            'part', 'particular', 'particularly', 'past',
            'per', 'perhaps', 'placed', 'please',
            'plus', 'poorly', 'possible', 'possibly',
            'potentially', 'pp', 'predominantly', 'present',
            'previously', 'primarily', 'probably', 'promptly',
            'proud', 'provides', 'put', 'q',
            'que', 'quickly', 'quite', 'qv',
            'r', 'ran', 'rather', 'rd',
            're', 'readily', 'really', 'recent',
            'recently', 'ref', 'refs', 'regarding',
            'regardless', 'regards', 'related', 'relatively',
            'research', 'respectively', 'resulted', 'resulting',
            'results', 'right', 'run', 's',
            'said', 'same', 'saw', 'say',
            'saying', 'says', 'sec', 'section',
            'see', 'seeing', 'seem', 'seemed',
            'seeming', 'seems', 'seen', 'self',
            'selves', 'sent', 'seven', 'several',
            'shall', 'she', 'shed', "she'll",
            'shes', 'should', "shouldn't", 'show',
            'showed', 'shown', 'showns', 'shows',
            'significant', 'significantly', 'similar', 'similarly',
            'since', 'six', 'slightly', 'so',
            'some', 'somebody', 'somehow', 'someone',
            'somethan', 'something', 'sometime', 'sometimes',
            'somewhat', 'somewhere', 'sorry',
            'specifically', 'specified', 'specify', 'specifying',
            'still', 'stop', 'strongly', 'sub',
            'substantially', 'successfully', 'such', 'sufficiently',
            'suggest', 'sup', 'sure t', 'take',
            'taken', 'taking', 'tell', 'tends',
            'th', 'than', 'thank', 'thanks',
            'thanx', 'that', "that'll", 'thats',
            "that've", 'the', 'their', 'theirs',
            'them', 'themselves', 'then', 'thence',
            'there', 'thereafter', 'thereby', 'thered',
            'therefore', 'therein', "there'll", 'thereof',
            'therere', 'theres', 'thereto', 'thereupon',
            "there've", 'these', 'they', 'theyd',
            "they'll", 'theyre', "they've", 'think',
            'this', 'those', 'thou', 'though',
            'thoughh', 'thousand', 'throug', 'through',
            'throughout', 'thru', 'thus', 'til',
            'tip', 'to', 'together', 'too',
            'took', 'toward', 'towards', 'tried',
            'tries', 'truly', 'try', 'trying',
            'ts', 'twice', 'two', 'u',
            'un', 'under', 'unfortunately', 'unless',
            'unlike', 'unlikely', 'until', 'unto',
            'up', 'upon', 'ups', 'us',
            'use', 'used', 'useful', 'usefully',
            'usefulness', 'uses', 'using', 'usually',
            'v', 'value', 'various', "'ve",
            'very', 'via', 'viz', 'vol',
            'vols', 'vs', 'w', 'want',
            'wants', 'was', 'wasnt', 'way',
            'we', 'wed', 'welcome', "we'll",
            'went', 'were', 'werent', "we've",
            'what', 'whatever', "what'll", 'whats',
            'when', 'whence', 'whenever', 'where',
            'whereafter', 'whereas', 'whereby', 'wherein',
            'wheres', 'whereupon', 'wherever', 'whether',
            'which', 'while', 'whim', 'whither',
            'who', 'whod', 'whoever', 'whole',
            "who'll", 'whom', 'whomever', 'whos',
            'whose', 'why', 'widely', 'willing',
            'wish', 'with', 'within', 'without',
            'wont', 'words', 'world', 'would',
            'wouldnt', 'www', 'x', 'y',
            'yes', 'yet', 'you', 'youd',
            "you'll", 'your', 'youre', 'yours',
            'yourself', 'yourselves', "you've", 'z',
            'zero'
        ]
        const STOPWORDS_MEDIUM = [
            'a', 'about', 'above', 'after',
            'again', 'against', 'all', 'am',
            'an', 'and', 'any', 'are',
            "aren't", 'as', 'at', 'be',
            'because', 'been', 'before', 'being',
            'below', 'between', 'both', 'but',
            'by', "can't", 'cannot', 'could',
            "couldn't", 'did', "didn't", 'do',
            'does', "doesn't", 'doing', "don't",
            'down', 'during', 'each', 'few',
            'for', 'from', 'further', 'had',
            "hadn't", 'has', "hasn't", 'have',
            "haven't", 'having', 'he', "he'd",
            "he'll", "he's", 'her', 'here',
            "here's", 'hers', 'herself', 'him',
            'himself', 'his', 'how', "how's",
            'i', "i'd", "i'll", "i'm",
            "i've", 'if', 'in', 'into',
            'is', "isn't", 'it', "it's",
            'its', 'itself', "let's", 'me',
            'more', 'most', "mustn't", 'my',
            'myself', 'name', 'no', 'nor',
            'not', 'of', 'off', 'on',
            'once', 'only', 'or', 'other',
            'ought', 'our', 'ours ourselves', 'out',
            'ought', 'our', 'ours ourselves', 'out',
            'over', 'own', 'same', "shan't",
            'she', "she'd", "she'll", "she's",
            'should', "shouldn't", 'so', 'some',
            'such', 'than', 'that', "that's",
            'the', 'their', 'theirs', 'them',
            'themselves', 'then', 'there', "there's",
            'these', 'they', "they'd", "they'll",
            "they're", "they've", 'this', 'those',
            'through', 'to', 'too', 'under',
            'until', 'up', 'very', 'was',
            "wasn't", 'we', "we'd", "we'll",
            "we're", "we've", 'were', "weren't",
            'what', "what's", 'when', "when's",
            'where', "where's", 'which', 'while',
            'who', "who's", 'whom', 'why',
            "why's", 'with', "won't", 'would',
            "wouldn't", 'you', "you'd", "you'll",
            "you're", "you've", 'your', 'yours',
            'yourself', 'yourselves'
        ]
        const STOPWORDS_CUSTOM = [
            'name', 'mobile', 'phone',
            'contact', 'number', 'buy',
            'packs', 'packets', 'packets',
            'product', 'products', 'want',
            'item', 'items', 'looking',
            'pieces', 'piece', 'hi',
            'named'
        ];
        const ENG_BAD_WORDS = [
            'fuck',
            'shit',
            'ass hole',
            'damn',
            'bitch',
            'dick',
            'cock',
            'don’t kiss my ass',
            'holy shit',
            'slut',
            'piss off',
            'olo'
        ]

Similarly stop words for Hindi:

मैं, मुझको, मेरा, अपने आप को
हमने
हमारा
अपना
हम
आप
आपका
तुम्हारा
अपने आप
स्वयं
वह
इसे
उसके
खुद को
कि वह
उसकी
उसका
खुद ही
यह
इसके
उन्होने
अपने
क्या
जो
किसे
किसको
कि
ये
हूँ
होता है
रहे
थी
थे
होना
गया
किया जा रहा है
किया है
है
पडा
होने
करना
करता है
किया
रही
एक
लेकिन
अगर
या
क्यूंकि
जैसा
जब तक
जबकि
की
पर
द्वारा
के लिए
साथ
के बारे में
खिलाफ
बीच
में
के माध्यम से
दौरान
से पहले
के बाद
ऊपर
नीचे
को
से
तक
से नीचे
करने में
निकल
बंद
से अधिक
तहत
दुबारा
आगे
फिर
एक बार
यहाँ
वहाँ
कब
कहाँ
क्यों
कैसे
सारे
किसी
दोनो
प्रत्येक
ज्यादा
अधिकांश
अन्य
में कुछ
ऐसा
में कोई
मात्र
खुद
समान
इसलिए
बहुत
सकता
जायेंगे
जरा
चाहिए
अभी
और
कर दिया
रखें
का
हैं
इस
होता
करने
ने
बनी
तो
ही
हो
इसका
था
हुआ
वाले
बाद
लिए
सकते
इसमें
दो
वे
करते
कहा
वर्ग
कई
करें
होती
अपनी
उनके
यदि
हुई
जा
कहते
जब
होते
कोई
हुए
व
जैसे
सभी
करता
उनकी
तरह
उस
आदि
इसकी
उनका
इसी
पे
तथा
भी
परंतु
इन
कम
दूर
पूरे
गये
तुम
मै
यहां
हुये
कभी
अथवा
गयी
प्रति
जाता
इन्हें
गई
अब
जिसमें
लिया
बड़ा
जाती
तब
उसे
जाते
लेकर
बड़े
दूसरे
जाने
बाहर
स्थान
उन्हें 
गए
ऐसे
जिससे
समय
दोनों
किए
रहती
इनके
इनका
इनकी
सकती
आज
कल
जिन्हें
जिन्हों
तिन्हें
तिन्हों
किन्हों
किन्हें
इत्यादि
इन्हों
उन्हों
बिलकुल
निहायत
इन्हीं
उन्हीं
जितना
दूसरा
कितना
साबुत
वग़ैरह
कौनसा
लिये
दिया
जिसे
तिसे
काफ़ी
पहले
बाला
मानो
अंदर
भीतर
पूरा
सारा
उनको
वहीं
जहाँ
जीधर
के
एवं
कुछ
कुल
रहा
जिस
जिन
तिस
तिन
कौन
किस
संग
यही
बही
उसी
मगर
कर
मे
एस
उन
सो
अत

Check match with regex and check if stop words doesnt exists, then pass
else fail.

We are having multiple inputs node where we are storing data into different different variables, we can not use different function to run regax.By using entity how can we procced?

This Function would easily follow Solid principles, where you won’t repeat or harm other areas of action.
You just need to apply this to validate if it’s a proper name. That’s the way to go.

Else you can only apply the 2 regexes I’ve mentioned initially to check if it’s a hindi or English word for a multilingual bot.

Thank You!

Please check the function as per your requirement.

  /**
 * Function to return all the stopwords in english and Hindi
 */
const stopWords = () => {
    return new Promise((resolve) => {
        const STOPWORDS_LONG = [
            'a', 'able', 'about', 'above', 'language', 'change', 'agent', 'branch',
            'abst', 'accordance', 'according', 'accordingly',
            'across', 'act', 'actually', 'added', 'end',
            'adj', 'affected', 'affecting', 'affects',
            'after', 'afterwards', 'again', 'against',
            'ah', 'all', 'almost', 'alone', 'feedback',
            'along', 'already', 'also', 'although',
            'always', 'am', 'among', 'amongst',
            'an', 'and', 'announce', 'another',
            'any', 'anybody', 'anyhow', 'anymore',
            'anyone', 'anything', 'anyway', 'anyways',
            'anywhere', 'apparently', 'approximately', 'are',
            'aren', 'arent', 'arise', 'around',
            'as', 'aside', 'ask', 'asking',
            'at', 'auth', 'available', 'away',
            'awfully', 'b', 'back', 'be',
            'became', 'because', 'become', 'becomes',
            'becoming', 'been', 'before', 'beforehand',
            'begin', 'beginning', 'beginnings', 'begins',
            'behind', 'being', 'believe', 'below',
            'beside', 'besides', 'between', 'beyond',
            'biol', 'both', 'brief', 'briefly',
            'but', 'by', 'c', 'ca',
            'came', 'can', 'cannot', "can't",
            'cause', 'causes', 'certain', 'certainly',
            'co', 'com', 'come', 'comes', 'contain',
            'containing', 'contains', 'could', 'couldnt', 'd',
            'date', 'did', "didn't", 'different', 'do',
            'does', "doesn't", 'doing', 'done', "don't",
            'down', 'downwards', 'due', 'during', 'e',
            'each', 'ed', 'edu', 'effect', 'eg',
            'eight', 'eighty', 'either', 'else', 'elsewhere',
            'end', 'ending', 'enough', 'especially', 'et',
            'et-al', 'etc', 'even', 'ever', 'every',
            'everybody', 'everyone', 'everything', 'everywhere', 'ex',
            'except', 'f', 'far', 'few', 'ff',
            'fifth', 'first', 'five', 'fix', 'followed',
            'following', 'follows', 'for', 'former', 'formerly',
            'forth', 'found', 'four', 'from', 'further',
            'furthermore', 'g', 'gave', 'get', 'gets',
            'getting', 'give', 'given', 'gives', 'giving',
            'go', 'goes', 'gone', 'got', 'gotten',
            'h', 'had', 'happens', 'hardly', 'has',
            "hasn't", 'have', "haven't", 'having', 'he',
            'hed', 'hence', 'her', 'here', 'hereafter',
            'hereby', 'herein', 'heres', 'hereupon', 'hers',
            'herself', 'hes', 'hi', 'hid', 'him',
            'himself', 'his', 'hither', 'home', 'how',
            'howbeit', 'however', 'hundred', 'i', 'id',
            'ie', 'if', "i'll", 'im', 'immediate',
            'immediately', 'importance', 'important', 'in', 'inc',
            'indeed', 'index', 'information', 'instead', 'into',
            'invention', 'inward', 'is', "isn't", 'it',
            'itd', "it'll", 'its', 'itself', "i've",
            'j', 'just', 'k', 'keep keeps', 'kept',
            'kg', 'km', 'know', 'known', 'knows',
            'l', 'largely', 'last', 'lately', 'later',
            'latter', 'latterly', 'least', 'less', 'lest',
            'let', 'lets', 'like', 'liked', 'likely',
            'line', 'little', "'ll", 'look', 'looking',
            'looks', 'ltd', 'm', 'made', 'mainly',
            'make', 'makes', 'many', 'may', 'maybe',
            'me', 'mean', 'means', 'meantime', 'meanwhile',
            'merely', 'mg', 'might', 'million', 'miss',
            'ml', 'more', 'moreover', 'most', 'mostly',
            'mr', 'mrs', 'much', 'mug',
            'must', 'my', 'myself', 'n',
            'na', 'name', 'namely', 'nay',
            'nd', 'near', 'nearly', 'necessarily',
            'necessary', 'need', 'needs', 'neither',
            'never', 'nevertheless', 'new', 'next',
            'nine', 'ninety', 'no', 'nobody',
            'non', 'none', 'nonetheless', 'noone',
            'nor', 'normally', 'nos', 'not',
            'noted', 'nothing', 'now', 'nowhere',
            'o', 'obtain', 'obtained', 'obviously',
            'of', 'off', 'often', 'oh',
            'ok', 'okay', 'old', 'omitted',
            'on', 'once', 'one', 'ones',
            'only', 'onto', 'or', 'ord',
            'other', 'others', 'otherwise', 'ought',
            'our', 'ours', 'ourselves', 'out',
            'outside', 'over', 'overall', 'owing',
            'own', 'p', 'page', 'pages',
            'part', 'particular', 'particularly', 'past',
            'per', 'perhaps', 'placed', 'please',
            'plus', 'poorly', 'possible', 'possibly',
            'potentially', 'pp', 'predominantly', 'present',
            'previously', 'primarily', 'probably', 'promptly',
            'proud', 'provides', 'put', 'q',
            'que', 'quickly', 'quite', 'qv',
            'r', 'ran', 'rather', 'rd',
            're', 'readily', 'really', 'recent',
            'recently', 'ref', 'refs', 'regarding',
            'regardless', 'regards', 'related', 'relatively',
            'research', 'respectively', 'resulted', 'resulting',
            'results', 'right', 'run', 's',
            'said', 'same', 'saw', 'say',
            'saying', 'says', 'sec', 'section',
            'see', 'seeing', 'seem', 'seemed',
            'seeming', 'seems', 'seen', 'self',
            'selves', 'sent', 'seven', 'several',
            'shall', 'she', 'shed', "she'll",
            'shes', 'should', "shouldn't", 'show',
            'showed', 'shown', 'showns', 'shows',
            'significant', 'significantly', 'similar', 'similarly',
            'since', 'six', 'slightly', 'so',
            'some', 'somebody', 'somehow', 'someone',
            'somethan', 'something', 'sometime', 'sometimes',
            'somewhat', 'somewhere', 'sorry',
            'specifically', 'specified', 'specify', 'specifying',
            'still', 'stop', 'strongly', 'sub',
            'substantially', 'successfully', 'such', 'sufficiently',
            'suggest', 'sup', 'sure t', 'take',
            'taken', 'taking', 'tell', 'tends',
            'th', 'than', 'thank', 'thanks',
            'thanx', 'that', "that'll", 'thats',
            "that've", 'the', 'their', 'theirs',
            'them', 'themselves', 'then', 'thence',
            'there', 'thereafter', 'thereby', 'thered',
            'therefore', 'therein', "there'll", 'thereof',
            'therere', 'theres', 'thereto', 'thereupon',
            "there've", 'these', 'they', 'theyd',
            "they'll", 'theyre', "they've", 'think',
            'this', 'those', 'thou', 'though',
            'thoughh', 'thousand', 'throug', 'through',
            'throughout', 'thru', 'thus', 'til',
            'tip', 'to', 'together', 'too',
            'took', 'toward', 'towards', 'tried',
            'tries', 'truly', 'try', 'trying',
            'ts', 'twice', 'two', 'u',
            'un', 'under', 'unfortunately', 'unless',
            'unlike', 'unlikely', 'until', 'unto',
            'up', 'upon', 'ups', 'us',
            'use', 'used', 'useful', 'usefully',
            'usefulness', 'uses', 'using', 'usually',
            'v', 'value', 'various', "'ve",
            'very', 'via', 'viz', 'vol',
            'vols', 'vs', 'w', 'want',
            'wants', 'was', 'wasnt', 'way',
            'we', 'wed', 'welcome', "we'll",
            'went', 'were', 'werent', "we've",
            'what', 'whatever', "what'll", 'whats',
            'when', 'whence', 'whenever', 'where',
            'whereafter', 'whereas', 'whereby', 'wherein',
            'wheres', 'whereupon', 'wherever', 'whether',
            'which', 'while', 'whim', 'whither',
            'who', 'whod', 'whoever', 'whole',
            "who'll", 'whom', 'whomever', 'whos',
            'whose', 'why', 'widely', 'willing',
            'wish', 'with', 'within', 'without',
            'wont', 'words', 'world', 'would',
            'wouldnt', 'www', 'x', 'y',
            'yes', 'yet', 'you', 'youd',
            "you'll", 'your', 'youre', 'yours',
            'yourself', 'yourselves', "you've", 'z',
            'zero'
        ]
        const STOPWORDS_MEDIUM = [
            'a', 'about', 'above', 'after',
            'again', 'against', 'all', 'am',
            'an', 'and', 'any', 'are',
            "aren't", 'as', 'at', 'be',
            'because', 'been', 'before', 'being',
            'below', 'between', 'both', 'but',
            'by', "can't", 'cannot', 'could',
            "couldn't", 'did', "didn't", 'do',
            'does', "doesn't", 'doing', "don't",
            'down', 'during', 'each', 'few',
            'for', 'from', 'further', 'had',
            "hadn't", 'has', "hasn't", 'have',
            "haven't", 'having', 'he', "he'd",
            "he'll", "he's", 'her', 'here',
            "here's", 'hers', 'herself', 'him',
            'himself', 'his', 'how', "how's",
            'i', "i'd", "i'll", "i'm",
            "i've", 'if', 'in', 'into',
            'is', "isn't", 'it', "it's",
            'its', 'itself', "let's", 'me',
            'more', 'most', "mustn't", 'my',
            'myself', 'name', 'no', 'nor',
            'not', 'of', 'off', 'on',
            'once', 'only', 'or', 'other',
            'ought', 'our', 'ours ourselves', 'out',
            'ought', 'our', 'ours ourselves', 'out',
            'over', 'own', 'same', "shan't",
            'she', "she'd", "she'll", "she's",
            'should', "shouldn't", 'so', 'some',
            'such', 'than', 'that', "that's",
            'the', 'their', 'theirs', 'them',
            'themselves', 'then', 'there', "there's",
            'these', 'they', "they'd", "they'll",
            "they're", "they've", 'this', 'those',
            'through', 'to', 'too', 'under',
            'until', 'up', 'very', 'was',
            "wasn't", 'we', "we'd", "we'll",
            "we're", "we've", 'were', "weren't",
            'what', "what's", 'when', "when's",
            'where', "where's", 'which', 'while',
            'who', "who's", 'whom', 'why',
            "why's", 'with', "won't", 'would',
            "wouldn't", 'you', "you'd", "you'll",
            "you're", "you've", 'your', 'yours',
            'yourself', 'yourselves'
        ]
        const STOPWORDS_CUSTOM = [
            'name', 'mobile', 'phone',
            'contact', 'number', 'buy',
            'packs', 'packets', 'packets',
            'product', 'products', 'want',
            'item', 'items', 'looking',
            'pieces', 'piece', 'hi',
            'named'
        ];
        const ENG_BAD_WORDS = [
            'fuck',
            'shit',
            'ass hole',
            'damn',
            'bitch',
            'dick',
            'cock',
            'don’t kiss my ass',
            'holy shit',
            'slut',
            'piss off',
            'olo'
        ]
        const hindiStopWords = []

        const STOPWORDS_ALL = [...STOPWORDS_LONG, ...STOPWORDS_MEDIUM, ...STOPWORDS_CUSTOM, ...ENG_BAD_WORDS, ...hindiStopWords]

        // const STOPWORDS_PRODUCT = [...STOPWORDS_MEDIUM, ...STOPWORDS_CUSTOM]
        resolve(STOPWORDS_ALL);
    });
}
return new Promise(async resolve => {
    // validate names of users
    const nameRegexEnglish = /^[a-zA-Z ]{2,30}$/gm;
    const nameRegexHindi = /^[\u0900-\u097F. ]{2,30}$/u
    const message = data.message // name typed by user
    console.log(message, 'message here')
    if (message.match(nameRegexEnglish)) {
        let stopWordArr = await stopWords();
        let nameArray = message.split(' ')
        console.log(nameArray, "nameArray")
        for(let i = 0; i < nameArray.length; i++) {
            if(stopWordArr.includes(nameArray[i].toLowerCase())) {
                resolve('no')
            }
        }
        resolve(message)
    }
    else {
        // console.log(message, 'false-->')
        return resolve('no')
    }
});                                                

please add your hindi list of stop words and add hindi regex logic.

Thanks for quick help. We will try this function.

Hi @Subhrajit_Gupta ,

We want to use entities to validate the user input, but using entities via regex, It’s not clearing the previous generated entities.
We are having multiple lengthy flows with N number of questions, So we can not use function approach here to validate the user input by creating separate function. It will be N number of function according to question(where we are storing response into diffrent different variables).

We tried with enitites approch,but it’s not clearing the previous entered entites value…Can you suggest on this??

Can you explain what you mean by entities not clearing.

Screenshot attached.
Trying to entered input- mahesh ,it’s validated for entity
trying to entered next input - ऐश्वर्या , Not taking to validate the entered enitity.Taking previous one.