1

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

  • 1
    You will need to better define what you mean by variant. Show some samples which would and should not match. – 0xCAFEBABE Nov 22 '13 at 10:08

3 Answers3

4

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".

h2ooooooo
  • 39,111
  • 8
  • 68
  • 102
0

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

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

Community
  • 1
  • 1
DavidC
  • 1,842
  • 1
  • 18
  • 32
0

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.