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
How to Solve this Regex Challenge
To complete the Currency-and-Percent-Free Number Finder challenge, you must write a regular expression pattern that satisfies all specified test cases.
Steps to Complete:
- Analyze the Requirements: Read the description and review the list of test cases below. Identify which strings must be matched (green markers) and which must be rejected (red markers).
- Draft Your Pattern: Enter your regex in the interactive editor. Use the provided Hint button if you get stuck.
- Verify: The test cases panel will update in real-time as you type, showing which strings match your current expression.
- Review the Solution: Once you successfully pass all test cases, review the explanation to understand the logic behind the solution.