sir_thursday
sir_thursday

Reputation: 5419

Regex match String with only one type of character

Trying to find a regex that matches to a String with only one type of character:

Example: "aaaaaa" or "a"

What expression would do this?

Upvotes: 1

Views: 1032

Answers (1)

falsetru
falsetru

Reputation: 369444

Using capturing group and backreference:

/^(.)\1*$/

According to the regular expression engine you're using you may need to replace \1 with $.

Upvotes: 2

Related Questions