You might also try, especially if "Some Text 1:" isn't standardized and you don't actually want the word "Data":
$str= "Some text1 : Data Some Text2"; $str=~/:\s+Data\s(.+)\z/; $youwant=$1; ##$1 is the captured (.+) part print $youwant;
prints "Some Text2"

It's not technically a substitution, of course -- $str remains the same -- but if you wanted to you could just set $str to $youwant at the end (or even to $1 earlier). or you could:
$str= "Some text1 : Data Some Text2"; $str=~s/.+?:\s+Data\s(.+)\z/$1/; print $str;
to use the substitution operator.. .

update: I thought the "Some Text2" WAS the data, and the "Data" was a literal (I don't know, announcing that a bunch of data was to follow, or something. Dense of me, I guess). My suggestions could be modified, but it would depend on what "Data" contained.

update2: dani_cv_72 looks quite a bit like dani_cv_perl, who posed very similar questions.

In reply to Re: Small replace regular exp help...pls by SamCG
in thread Small replace regular exp help...pls by dani_cv_74

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.