in reply to regexp parsing from a big string...

You could:

use strict; use warnings; my $tempStr = <<'STR'; sdfasdfsdfsd asdfasdfasdfasdfsdfsd ... is_raw_sql_editor = FALSE" STR open my $inFile, '<', \$tempStr; local $/ = "\n\n"; # Break input into paragraphs while (<$inFile>) { chomp; next unless length; next unless / User\s+(\w+).*? phone\s*=\s*(\w*).*? email\s*=\s*(\w*).*? misc_info\s*=\s*(.*) /xs; print "User $1, phone $2, email $3, misc_info:\n$4\n\n"; }

Prints:

User soandso, phone , email a, misc_info: is_superuser = TRUE is_appbuilder = TRUE is_packagehacker = FALSE is_user_maint = TRUE authentication = CQ is_dynamic_list_admin = FALSE is_public_folder_admin = FALSE is_security_admin = FALSE is_raw_sql_editor = FALSE User soandso1, phone , email a, misc_info: is_superuser = TRUE is_appbuilder = TRUE is_packagehacker = FALSE is_user_maint = TRUE authentication = CQ is_dynamic_list_admin = FALSE is_public_folder_admin = FALSE is_security_admin = FALSE is_raw_sql_editor = FALSE"

which scales nicely to obtaining the input from a file.


Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^2: regexp parsing from a big string...
by johngg (Canon) on May 13, 2008 at 09:40 UTC
    I think that your (\w*) for the email address is not working, it seems to be dropping the "@b.com" that is in the string. Perhaps (\S*) would do the trick (not tested).

    Cheers,

    JohnGG