Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: indexing in strings

by BrowserUk (Patriarch)
on Nov 24, 2012 at 14:38 UTC ( [id://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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1005378]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-20 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found