# Regex based entity extraction in rasa

**URL:** <https://forum.rasa.com/t/regex-based-entity-extraction-in-rasa/25139>\
**Category:** Rasa Open Source\
**Created:** [February 22, 2020, 12:37am UTC](https://forum.rasa.com/t/regex-based-entity-extraction-in-rasa/25139 "2020-02-22T00:37:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sidkgp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sidkgp/32/3276_2.png) [@sidkgp](https://forum.rasa.com/u/sidkgp)\
**Post date:** [February 22, 2020, 12:37am UTC](https://forum.rasa.com/t/regex-based-entity-extraction-in-rasa/25139/1 "2020-02-22T00:37:20Z")

</div>

I want to update my entities with regex. [Entity Extraction](https://rasa.com/docs/rasa/nlu/entity-extraction/#regular-expressions-regex) says it can be done post-NLU. Would it be possible to get an example as to where in rasa’s code to insert the reflex matching?

---

<div class="post-metadata">

**Author:** ![degiz](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/degiz/32/9936_2.png) [@degiz](https://forum.rasa.com/u/degiz)\
**Post date:** [March 4, 2020, 4:28pm UTC](https://forum.rasa.com/t/regex-based-entity-extraction-in-rasa/25139/2 "2020-03-04T16:28:12Z")

</div>

Hey @sidkgp

I believe that you’re looking for slot validation in action.py file.

You can check the usage example [here](https://github.com/RasaHQ/rasa/blob/master/examples/formbot/actions.py), method validate\_cuisine().

---

<div class="post-metadata">

**Author:** ![sidkgp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/sidkgp/32/3276_2.png) [@sidkgp](https://forum.rasa.com/u/sidkgp)\
**Post date:** [March 18, 2020, 10:01am UTC](https://forum.rasa.com/t/regex-based-entity-extraction-in-rasa/25139/3 "2020-03-18T10:01:35Z")

</div>

I am actually not looking to fix the false positives (for which your solution is great), but want to catch false negatives (or improve recall) through regexes. For example, I want to say all [0-9]{5} is zipcode and catch stuff that is missed by rasa’s default entity recognizers.

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [March 31, 2020, 12:30pm UTC](https://forum.rasa.com/t/regex-based-entity-extraction-in-rasa/25139/4 "2020-03-31T12:30:15Z")

</div>

Hey @sidkgp you can do some regex matching from within a custom action, by getting the `tracker.latest_message` and doing e.g. `re.search()` on that. Then you can store whatever you find there in a slot

But the example you mention (and any other entities like numbers, time, amount of money etc) can be handled by the [duckling entity extractor](https://rasa.com/docs/rasa/nlu/components/#ducklinghttpextractor)
