Relative Date Words
beginnerMatches common relative date expressions like 'yesterday', '3 days ago', 'next week'.
daterelativenatural-languageparsing
Pattern
/(?:today|yesterday|tomorrow|(?:\d+\s+)?(?:days?|weeks?|months?|years?)\s+ago|(?:next|last)\s+(?:week|month|year))/giTry It
0 of 8 strings matched
Explanation
Matches relative date expressions: 'today', 'yesterday', 'tomorrow', N units ago, or next/last week/month/year.
Test Strings
Matching
- yesterday
- 3 days ago
- next week
- last month
- today
Non-matching
- 2024-01-15
- Monday
- next hour
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:today|yesterday|tomorrow|(?:\d+\s+)?(?:days?|weeks?|months?|years?)\s+ago|(?:next|last)\s+(?:week|month|year))/gi;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);