Ron AndKim Stengel
Ron AndKim Stengel

Reputation: 113

Regex expression to catch variant of a word

I am looking for simple way to use regex and catch variant of word with simplest format. For example, the 5 variants of the word below.

hike hhike hiike hikke hikkee

Using something similar to the format below...

[([a-zA-Z]){4,}]

Thanks

Upvotes: 1

Views: 131

Answers (3)

DavidC
DavidC

Reputation: 1862

This is more of a soundex kind of problem I think:

https://stackoverflow.com/a/392236/514463

Upvotes: 0

user3012345
user3012345

Reputation: 25

You probably cannot solve this generically (i.e. for any word) under standard regex syntax.

For a given word, as others have pointed out, it is trivial.

Upvotes: 0

h2ooooooo
h2ooooooo

Reputation: 39540

Are you looking for something like /h+i+k+e+/?

Meaning:

  • The literal h character repeated 1 to infinity times
  • The literal i character repeated 1 to infinity times
  • The literal k character repeated 1 to infinity times
  • The literal e character repeated 1 to infinity times

DEMO

If each character can maximum be there twice, you can use /h{1,2}i{1,2}k{1,2}e{1,2}/ meaning "present 1 or 2 times".

Upvotes: 4

Related Questions