Skip to main content
Regexflux

Relative Date Words

beginner

Matches 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))/gi

Try 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

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull 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);

Related Patterns