Search code examples
pythonamazon-web-servicesamazon-lex

what will be the Regular expression?


What will be the regular expression for salary i.e "2 lakhs" or "3.4 lakhs" or "3.4" in python for Amazon Lex? I tried this

ctc_regex = re.compile(r'^[0-9]+(\.[0-9]{1,2})"lakhs"?$')

Solution

  • First of all, replace quotes around lakhs on braces and add space in it. Also, make point and numbers after it optional too.

    ^[0-9]+(\.[0-9]{1,2})?( lakhs)?$

    See test here https://regex101.com/r/5DAo6S/1