Reputation: 113
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
Reputation: 1862
This is more of a soundex kind of problem I think:
https://stackoverflow.com/a/392236/514463
Upvotes: 0
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
Reputation: 39540
Are you looking for something like /h+i+k+e+/
?
Meaning:
h
character repeated 1 to infinity timesi
character repeated 1 to infinity timesk
character repeated 1 to infinity timese
character repeated 1 to infinity timesIf 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