-1

I'd like to find these three strings in any order and the result may have all these three strings including any character between them with the shortest length.

strings are: "ACT", "AGT" and "CGT".

Sample input: "ACTACGTTTAGTAACTCGTCT"

I tried but the regex returns the first occurrence matched which is "ACTACGTTTAGTAACTCGT"

/(ACT.*AGT.*CGT)|(ACT.*CGT.*AGT)|(AGT.*ACT.*CGT)|(AGT.*CGT.*ACT)|(CGT.*ACT.*AGT)|(CGT.*AGT.*ACT)/g

Output has to be "AGTACTCGT"

gandarez
  • 2,609
  • 4
  • 34
  • 47

1 Answers1

-1

You can't return separate bits of a string already concatenated in one go.

See here: Regular expression to skip character in capture group

You can first match each bit, using parentheses to group them, and then put them together in a separate step