Regular Expressions 101

Community Patterns

First and Last character Match

0

Regular Expression
PCRE (PHP <7.3)

/
^([a-b]).*\1$|^[a-b]{1}$
/
gm

Description

This expression matches first and last character as well as check for the string if length is 1 or not if it is simply check the first character.

Submitted by anonymous - 4 years ago