+ Reply to Thread
Results 1 to 2 of 2

Thread: remove extra string

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    31

    remove extra string

    I have a string like :
    Code:
    MyNew_text_anything_after text_is not needed_123
    What i need is shrink the text so that i could only keep
    Code:
    MyNew_text
    and delete the rest.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    35
    You can use the lookbehind method , for example:
    Code:
    my $str = "MyNew_text_anything_after text_is not needed_123"
    $str =~ s/(?<=MyNew_text_)\D+//gi;
    print $str;
    This will replace all non-digit symbols that follow this anchor.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts