-1

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"?$')
sepp2k
  • 363,768
  • 54
  • 674
  • 675
  • 2
    can you please elaborate your question? are you just trying to match [2 lakhs, 3.4 lakhs, 3.4] or all values in between. If these are just three values you are trying to compare use list of values and comaprision opereator instead of regex. – Pooja Oct 09 '19 at 08:04
  • @Pooja these values are just the examples. I need lex to accept all the possible values that the user can input for CTC slot. – chetan kargeti Oct 17 '19 at 12:16

1 Answers1

1

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

P. Dmitry
  • 1,123
  • 8
  • 26