Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Re: finding substring from index a to b

  •  09-27-2007, 9:04 PM

    Re: finding substring from index a to b

    Hi Susan,

     

    That was great !!

    I am almost there - just one problem now.

     

    Suppose my sample input.txt file now has just one line -

    AAAAAGGGGGAAAAATTTTT

     

    Now I want to use one of the command line utilities to PRINT on the screen the first matched group (or the first backreference.) I want to print the backreference ONLY.

     

    I tried

    a.

    [shell]$ perl -pe '/.{5}(.{5})/' input.txt

    it gave  AAAAAGGGGGAAAAATTTTT

     

    b.

    [shell]$ grep -oP ".{5}(.{5})" input.txt


    AAAAAGGGGG
    AAAAATTTTT

     

    I just want to print the GGGGG on the screen from my input file.

    Is there a quick way to do that using grep itself (I mean, of printing \1? ) or can I concatenate commands in "perl -pe"? or can I use any other single line command?

     

    This is the last step :)

     

    Thanks a lot for the help though! 

     

     

    Filed under:
View Complete Thread