in reply to Re: remove specific data from a line
in thread remove specific data from a line

I not explain too good sorry. Let me try eloborate. String could look like this
abc123 qwerty,asdfg,zxcvb yuio jklh
or like this
abc987 qwerty yuio jklh
or this
abcefgh qwerty, asdfg yuio jklh
So I want to end up with same string from all examples above. It should end up like this
yuio jklh
Hope this make it bit clearer, sorry for confuse my english not so good

Replies are listed 'Best First'.
Re^3: remove specific data from a line
by graff (Chancellor) on Feb 03, 2006 at 03:17 UTC
    Given those examples, there might be a few ways to do this -- either try to match from the start of the string:
    s/abc\w+\s+\w+(?:, *\w+)\s+//; # match and remove unwanted initial co +ntent
    or else just look for what you want to keep at the end:
    s/.*\s(\w+\s+\w+)$/$1/; # match desired end content and remove everyt +hing before it
    And of course, if you know in advance how those last two tokens are spelled, you could even use rindex() and substr():
    $_ = substr( $_, rindex( $_, 'yuio jklh' ));
      Thank for answer but not quite what I look for. This  s/abc\w+\s+\w+(?:, *\w+)\s+//; only work correct on last line of my example.
      I'm not able to use second or third option you supply because I do not know what end of line hold only what beginning of line look like. See my reponse to Roy Johnson. Thanks