user3769571
user3769571

Reputation: 65

Finding sequences with noise in a string

So, if I have a string like 110110110, as you can see that, the sequence 110 is continuously appearing.

Upvotes: 0

Views: 87

Answers (1)

pushpraj
pushpraj

Reputation: 13679

here you go

Regex

(\w{3,})\1

Test string

110110111
110111111
a0cc0vaaaabaaaabaaaacaa00bvw

Result

  • MATCH 1
      1. [0-3] 110
  • MATCH 2
      1. [13-16] 111
  • MATCH 3
      1. [26-31] aaaab

demo here

regex is based on assumptions that pattern is at least 3 char long

Upvotes: 2

Related Questions