/^/
ExpertText Extraction

Currency-and-Percent-Free Number Finder

Write a regex that matches a whole number only when it is neither immediately preceded by a dollar sign nor immediately followed by a percent sign, isolating plain quantities from prices and percentages in the same sentence.

//
$100 total / 50% discount / I have 30 apples / Save $5 now / Get 100% refund / Room number 42

Test cases

  • $100 totalexpect no match
  • 50% discountexpect no match
  • I have 30 applesexpect match
  • Save $5 nowexpect no match
  • Get 100% refundexpect no match
  • Room number 42expect match
  • $20 off gives 15% savings but 7 apples remainexpect match