Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I have 2 strings, with one being a substring of the other, like: $big_string=... & $small_string=... For the small string I have a label string: $label_for_small=... 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.

Add Is & Os ... to what? The big string? The small string? The label string? A post-it on the back of your keyboard?

I'm thinking to use index, would this be efficient solution?

Yes. index locates strings within strings efficiently.

But your description of what you then want to do is about as clear as mud.

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?

So you want to grow the small string to be the same length as the big one? If so, what is the label for?

Your label seems to contain the Is & Os you mention, but as the label is shirt than the big string, and you have mamy of each, they do not represent the start and end positions of the matched substring? And what are the Ms for?

Try asking your question again, this time imagine you are explaining it to someone with no knowledge of computers.

You might also like to give an example of (much shorter!) inputs and the required output(s).

A picture is worth a thousand words.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


In reply to Re: indexing in strings by BrowserUk
in thread indexing in strings by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (8)
    As of 2014-12-27 21:32 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (177 votes), past polls