Need Regex for to match special situations

Posted by Daniel on Stack Overflow See other posts from Stack Overflow or by Daniel
Published on 2010-05-18T09:16:40Z Indexed on 2010/05/18 9:21 UTC
Read the original article Hit count: 149

Filed under:
|
|

I'm desperately searching for regular expressions that match these scenarios:

1) Match alternating chars

I've a string like "This is my foobababababaf string" - and I want to match "babababa"

Only thing I know is the length of the fragment to search - I don't know what chars/digits that might be - but they are alternating.

I've really no clue where to start :(

2) Match combined groups

In a string like "This is my foobaafoobaaaooo string" - and I want to match "aaaooo". Like in 1) I don't know what chars/digits that might be. I only know that they will appear in two groups.

I experimented using (.)\1\1\1(.)\1\1\1 and things like this...

© Stack Overflow or respective owner

Related posts about regex

Related posts about groups