CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions:
First in Perl expression - CreateTask('', '', 'qwe123_')


New User

May 6, 2011, 2:46 AM

Post #1 of 2 (7665 views)
First in Perl expression - CreateTask('', '', 'qwe123_') Can't Post

need create regular expression for such string
CreateTask('qwe123_', 'qwe123_', "qwe123_")

the qoutes can be ' or "
between all parts can be any whitespace, tabs and even returns.

I start trying with it - CreateTask('\w*',m/(\t|\s)/* but its not even compiled(



May 6, 2011, 10:23 AM

Post #2 of 2 (7660 views)
Re: [Yola] First in Perl expression - CreateTask('', '', 'qwe123_') [In reply to] Can't Post

Why not start with something even more basic like the following:

my $str = qq{ asdf  CreateTask('qwe123_', 'qwe123_', "qwe123_") asdfqwe}; 

if ($str =~ m/(CreateTask\(.*?\))/s) {
print $1;
} else {
warn "Func not found\n";

Note the use of the 's' modifier so that teh any character '.' will match returns. .*? is for non-greedy matching, so it will stop at the first ')'.

The only place where this will fail is if there are parenthesis within one of your string parameters. It would be possible to create a regex for that as well, but wanted to start with something simpler.

- Miller


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives