Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: indexing in strings

by BrowserUk (Pope)
on Nov 24, 2012 at 14:38 UTC ( #1005378=note: print w/replies, xml ) Need Help??

in reply to indexing in strings

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005378]
Discipulus must prepare some ammunitions: XML::Compile::SOAP but what the heck!

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2017-06-27 09:02 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (601 votes). Check out past polls.