flashtext
flashtext copied to clipboard
How to use Regular Expression with FlashText
This is probably an easy question that is already been answered but unfortunately, I can't figure this out or find someone that did already.
How can I use FlashText for Regex patterns?
Something that comes to mind a possible ways but doesn't work is:
from flashtext import KeywordProcessor
keyword_processor = KeywordProcessor()
keyword_processor.add_keyword('Big')
keyword_processor.add_keyword(r'\d{5}')
keywords_found = keyword_processor.extract_keywords('I love big Appsle 23234 ands Bay Area. 12345', span_info=True)
print(keywords_found)
As a result, we will have "big" and the corresponding position and "23234, 12345" and the corresponding position
Thank you for taking the time to answer me and excited to use your great library
Hi @milts10 ,
Unfortunately flashtext cannot handle regex patterns. You should use the regex module instead.
Kind regards, Nandan Thakur
Thank you so much for answering,
I am sorry for being such a newbie but what is the regex module and can I find the position of the regex using this module?
Basically, the only thing that I need is to input 2 different regexes for example and get back the position of this regex in the input text
Thank you for your time!!!!!
Thank you so much for answering,
I am sorry for being such a newbie but what is the regex module and can I find the position of the regex using this module?
Basically, the only thing that I need is to input 2 different regexes for example and get back the position of this regex in the input text
Thank you for your time!!!!!
@milts10 hello,I have the same question,How did you solve it?
@JJwangbilin Are you looking for this?