3dbc has asked for the wisdom of the Perl Monks concerning the following question:
My thought was to convert this mess to a regex substitution.
to something like ---$bday = "8/16/97"; $firstname = "Benjamin"; $lastname = "Biederman"; @DOB = split /\//, $bday; @month = split //, $DOB[0]; @day = split //, $DOB[1]; $digits_month = @month; $digits_day = @day; $temp_month = $DOB[0]; $temp_day = $DOB[1]; if ($digits_month==1) { $bday = "0"; $bday .= $temp_month; } else { $bday = $temp_month; } if ($digits_day==1) { $bday .= "0"; $bday .= $temp_day; } else { $bday .= $temp_day; } @new_username_a = split //, $firstname; @new_username_b = split //, $lastname; $login_name = lc $new_username_a[0]; $login_name .= lc $new_username_b[0]; $login_name .= $bday;
Thanks,$login_name = "$firstname $lastname $bday"; $login_name = s/^(^\C)\s(^\C)\s(^\d{1,2})\/(\d{1,2})\/(\d{1,2})/$1$2$3 +$4/; #notice that to 2 digit bit is not reflected by this regex
janitored by ybiC: Balanced <code> tags around code only, retitle from " REGEX optimization" for better searching
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Convert split to regex
by holo (Monk) on Dec 08, 2003 at 20:06 UTC | |
|
Re: Convert split to regex
by Zed_Lopez (Chaplain) on Dec 08, 2003 at 20:07 UTC | |
by Not_a_Number (Prior) on Dec 08, 2003 at 20:52 UTC | |
|
Re: Convert split to regex
by Aristotle (Chancellor) on Dec 09, 2003 at 13:18 UTC |