Rafa Tost
Rafa Tost

Reputation: 399

Limit this javascript regex match to 26 character results

I am using this regex to match hastags #LIKE #this

It works great.

/(?!\b)(#\w+\b)/g

But i would like to limit it to hashtags with 26 characters.

Can i modify this to get this result?

Upvotes: 1

Views: 332

Answers (1)

anubhava
anubhava

Reputation: 785196

But i would like to limit it to hashtags with 26 characters.

/(?!\b)(#\w{1,26}\b)/g

should work.

Basically you replace \w+ (1 or more word characters) with \w{1,26} (between 1 to 26 word characters)

Upvotes: 3

Related Questions