I feel like I should make clear that I don't know where abouts in the string it will be, I just know that it is in there somewhere.
If you know the content of the sub-string literally in advance and know that it is there, then why would you want to look for it? Well, it you want to check that it is really there, or want to know where in the string it is, then maybe you want to try the index (or, possibly but less likely, the rindex) function. But I suspect that's not really what you want.

The problem, though, it that you did not state what you want. I would suspect you probably want to use a regex to find a sub-string that you don't know exactly in advance, but that matches certain criteria or pattern. If this is the case, please provide more information about what you know about that sub-string.


In reply to Re: Get a known substring from a string by Laurent_R
in thread Get a known substring from a string by jake7176

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.