Perlinn Perlinn - 1 month ago 22
Python Question

Regex expression excluding "-" tag

Hi right now my regex expression is working as intended. However i wish to specifically exclude items such as
how do i update my regex such that it would exclude entries with "-\d*"/ negative quantity? ?

https://regex101.com/r/4EUzLo/1

Answer

This should work for you:

'\d+\s*([a-zA-Z].*\w)\s+\d.*'

The '\d+ will only match the positive quantities, and with less steps.

Now, just extract the info from the capture group.

Demo

Comments