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

  •  10-01-2007, 4:10 PM

    Re: finding substring from index a to b

    Hi Susan,

     

    This works great ... but now there is one last problem ...

     

    Now my input file is this:

     

    CAAATAACTTCGAGATTATAGT
    GAGATTATAGTCAAATAACTTC
    AGTCAAACAAATAACTTCGAGA

     

    And I am running this command on it: 

    perl -pe '/.{1}(.{10})/;$_="$1\n";' test2.txt

     

    And the output I am getting is:

     

    AAATAACTTC
    AGATTATAGT
    GTCAAACAAA

     

     

    But I want only "AAATAACTTC" to be displayed and not the other strings i.e. I want to suppress the output after the first match is found.

     

    As a remedy, I can chomp the whole file at the start as follows:

     

    perl -pe 'chomp' test2.txt | perl -pe '/.{1}(.{10})/;$_="$1\n";'

     

    And this works fine, but again, since my files are too large, chomp is not working for them anyway. And so I am getting all matches occuring at all new lines.

     

    I am unsure how to handle this problem now :(

    Any inputs will be very helpful.

     

    Thanks. 

    Filed under:
View Complete Thread