Regular Expressions 101

Community Patterns

123...6

Match last repetition and remove it

1

Regular Expression
ECMAScript (JavaScript)

/
(a+)(.*)(\1)
/
g

Description

Remove the last repetition of a on texts like:

a b c d a e f g

Submitted by Icaruk - a year ago