regex - Regular expression Capture and Backrefence -


here's string i'm searching.

t+4accgt+12caagtactaccgt+12caagtactaccgt+4accga+6ctaccgt+12caagtactaccgt+12caagtactaccg 

i want capture digits behind number x digits (x being previous number) want capture complete string.

ie capture should return:

+4accg +12aagtactaccgt etc. 

and :

accg aagtactaccgt etc. 

here's regex i'm using:

(\+(\d+)([atgcatgcnn]){\2}); 

and i'm using $1 , $3 captures.

what missing ?

this loop works because \g assertion tells regex engine begin search after last match , (digit(s)), in string.

$_ = 't+4accgt+12caagtactaccgt+12caagtactaccgt+4accga+6ctaccgt+12caagtactaccgt+12caagtactaccg';  while (/(\d+)/g) {     $dig = $1;     /\g([tagcn]{$dig})/i;     $1; } 

the results are

accg caagtactaccg caagtactaccg accg ctaccg caagtactaccg caagtactaccg 

i think correct not sure :-|

update: added \g assertion tells regex begin after last matched number.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -