EasyText Processing
Leading/Trailing Whitespace Finder
Write a regex you could pass to .replace() to detect whitespace that sits at the very start or very end of a string (the kind you'd want to trim), while ignoring whitespace in the middle of the text.
//
' hello' / 'hello ' / 'hello' / ' hello ' / 'h e l l o'
Test cases
- helloexpect match
- hello expect match
- helloexpect no match
- hello expect match
- h e l l oexpect no match
- expect match
How to Solve this Regex Challenge
To complete the Leading/Trailing Whitespace 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.