John
John

Reputation: 3050

Why doesn't the Regex match?

@^/yolo/[a-z]$@

and I am trying to match /yolo/test

but it doesn't match... What in the regular expression can be wrong? It seems perfectly fine to me.

Upvotes: 0

Views: 91

Answers (2)

Dan
Dan

Reputation: 4512

As written, this will match /yolo/ followed by any single letter. I suspect you want to match one or more letters, as in:

@^/yolo/[a-z]+$@

Upvotes: 5

Vorsprung
Vorsprung

Reputation: 34367

^/yolo/[a-z]$

^ means match start of line

/yolo/ matches literally the string /yolo/

[a-z] matches one character, a to z

$ matches the end of line

So you are looking for /yolo/ followed by a single character

Which does not match /yolo/test

Upvotes: 2

Related Questions