Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hey there,
I have 2 strings, with one being a substring of the other, like:
What I would like to do is to first identify the "small" substring into the "big" one, and then add, respectively, 'I's and 'O's (or the opposite) in the start and end positions. I'm thinking to use index, would this be efficient solution? And how would I know how many 'O's and 'I's must I add in order for the "small" substring to grow into the length of the "big" one?
Thanks!
I have 2 strings, with one being a substring of the other, like:
For the small string I have a label string:$big_string="MAAAAATLRGAMVGPRGAGLPGARARGLLCGARPGQLPLRTPQAVSLSSKSGLSRGR +KVILSALGMLAAGGAGLAVALHSAVSASDLELHPPSYPWSHRGLLSSLDHTSIRRGFQVYKQVCSSCHS +MDYVAYRHLVGVCYTEDEAKALAEEVEVQDGPNEDGEMFMRPGKLSDYFPKPYPNPEAARAANNGALPP +DLSYIVRARHGGEDYVFSLLTGYCEPPTGVSLREGLYFNPYFPGQAIGMAPPIYNEVLEFDDGTPATMS +QVAKDVCTFLRWAAEPEHDHRKRMGLKMLLMMGLLLPLVYAMKRHKWSVLKSRKLAYRPPK"; $small_string="SDLELHPPSYPWSHRGLLSSLDHTSIRRGFQVYKQVCSSCHSMDYVAYRHLVGVC +YTEDEAKALAEEVEVQDGPNEDGEMFMRPGKLSDYFPKPYPNPEAARAANNGALPPDLSYIVRARHGGE +DYVFSLLTGYCEPPTGVSLREGLYFNPYFPGQAIGMAPPIYNEVLEFDDGTPATMSQVAKDVCTFLRWA +AEPEHDHRKRMGLKMLLMMGLLLPLVYAMKRHKWSVLKSRKLAYRPPK";
$label_for_small="OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO +OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO +OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO +OOOOOOOOOOOOOOOMMMMMMMMMMMMMMMMMMIIIIIIIIIIIIIIIIII";
What I would like to do is to first identify the "small" substring into the "big" one, and then add, respectively, 'I's and 'O's (or the opposite) in the start and end positions. I'm thinking to use index, would this be efficient solution? And how would I know how many 'O's and 'I's must I add in order for the "small" substring to grow into the length of the "big" one?
Thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: indexing in strings
by roboticus (Chancellor) on Nov 24, 2012 at 14:02 UTC | |
by Anonymous Monk on Nov 24, 2012 at 14:12 UTC | |
Re: indexing in strings
by BrowserUk (Patriarch) on Nov 24, 2012 at 14:38 UTC | |
Re: indexing in strings
by AnomalousMonk (Archbishop) on Nov 24, 2012 at 15:59 UTC | |
Re: indexing in strings
by LanX (Saint) on Nov 24, 2012 at 15:31 UTC |
Back to
Seekers of Perl Wisdom