Regular Expressions 101

Community Patterns

Convert YYMMDD to DD/MM/YY

1

Regular Expression
PCRE (PHP <7.3)

/
(\d{2})(\d{2})(\d{2})
/

Description

I'm new to regular expressions and I've been searching high and low for this really simple date conversion from YYMMDD to DD/MM/YY e.g. 140923 to 23/09/14. Maybe I just didn't search hard enough, but here goes:

Search/original string:

(\d{4})(\d{2})(\d{2})

Replace string

$3/$2/$1

Submitted by Nike Begbaaji - 10 years ago