in reply to Find string match

$str =~ /into\s(.*?)\(/

Now you should have your name in the variable $1.

(see also the following info on regexes and greediness)


HTH, Rata

Replies are listed 'Best First'.
Re^2: Find string match
by Utilitarian (Vicar) on Feb 23, 2010 at 12:58 UTC
    Not quite
    ($tablename) = $str=~/\binto\s+([\S]+)/; Updated: on foot of cdarke's observations below

    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
      Not quite
      The match returns 1 (true). Maybe you are thinking of s?
      $str=~/\binto\s+(\S+)/; my $tablename = $1;
      [^\s] is better written as \S
        Actually 1 is the size of the array of matches.

        print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
      Or maybe:
      my $tablename = ($str=~/\binto\s+([^\s]+)/)[0];

        Less obscure:

        $s = 'insert into table1 ( v1, v2 , v3) values ( v1, v2, v3)';; ( $tname ) = $s =~ m[into\s+(\S+)\s?\(]; print $tname;; table1

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Find string match
by ddragosa (Acolyte) on Feb 23, 2010 at 12:59 UTC

    Thanks. I forget about the "?" after the (.*)