in reply to take out section of a string then put it back
BTW, it's more efficient to use groups--the stuff in parens--in your reg exp instead of $`,$&,$'. So:#!/usr/bin/perl -w use strict; my $temp = "Firstword and then the rest of the string"; $temp =~ /^(\w+)/i; my $firstword = $1;
my $temp = "Firstword and then the rest of the string"; $temp =~ /^(\w+)([ \w]*)/i; my $firstword = $1; my $restofstring = $2;
|
|---|