Re: Search string without using regexp
by zwon (Abbot) on Jun 09, 2012 at 10:46 UTC
|
| [reply] |
|
|
Three word magic! Three words written by you are more impacting than the entire two big paragraphs written in the previous posts!
Thanks!!
| [reply] |
|
|
| [reply] |
Re: Search string without using regexp
by stevieb (Canon) on Jun 09, 2012 at 10:05 UTC
|
| [reply] |
|
|
lol...i respect your opinion...but that what was asked to me in a job interview and i am wondering whether its possible.
and your reply is making me believe you are someone who knows how to do it.
| [reply] |
|
|
You could say I am someone who knows how to do it...
Given this is an interview question, I'm quite concerned to be honest, especially given your analysis on the future of Perl.
If you are being interviewed and can't answer this, how are you qualified to provide analysis, particularly statistical on the usage of Perl?
What exactly is it you want to know? Are you just looking for someone to give you a syntax answer so we can satisfy the requirement of some dev team director that doesn't know his ass from a hole in the ground? ;) I'll be watching for further responses. For now, I don't have one. I'm sorry.
| [reply] |
A reply falls below the community's threshold of quality. You may see it by logging in.
|
Re: Search string without using regexp
by kcott (Archbishop) on Jun 09, 2012 at 12:37 UTC
|
| [reply] |
|
|
mmmm...i think substr requires prior knowledge of position of substring. index seems to be the correct option to me.
Please correct me if i am wrong.
| [reply] |
|
|
index lets you search a string quickly for an exact match, or find an exact match after some position, or walk the string finding each exact match (by advancing the starting position each time).
substr will return a substring, which you could then programatically process and test for some condition if you want. If you want to find the first position in a string where a four character sequence looks a particular way after the digits are reversed, you might walk the string using substr, advancing the position after each check (a bad example, since it's cheaper to just reverse the whole string and then use index, subtracting four from the result).
index is a more specific function, and substr is a more general function that can be incorporated into a more specific solution.
| [reply] |
|
|
| [reply] [d/l] [select] |