in reply to Replacing parts of a string
Use CGI.pm to do it for you thusly (this is very robust):
$str = "calendarview.pl?loginid=102138&month=04&year=2003&student_id=& +user_type=TUTOR&CalendarName=102138Academic&framename=top.index_main& +session_number=618280744437303"; # first amputate the calendarview.pl? bit $str =~ s/^[^\?]+\?//; # use CGI.pm to parse the string by creating a CGI instance from it use CGI; $q = CGI->new($str); # modify whatever you want, lets delete what you specified $q->delete('CalendarName'); $q->delete('month'); $q->delete('year'); # and modify loginid just for laughs $q->param( 'loginid', 'haxor' ); # add a new param if you want $q->param('i am a new one', 'this is my value' ); # write out the new query string (default is to use ; not & so we do:) $CGI::USE_PARAM_SEMICOLONS = 0; print $q->query_string(); __DATA__ loginid=haxor&student_id=&user_type=TUTOR&framename=top.index_main&ses +sion_number=618280744437303&i%20am%20a%20new%20one=this%20is%20my%20v +alue
You will be hard pressed to break this solution - it is much better than using regexes from a robustness point of view.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Replacing parts of a string
by spiderbo (Sexton) on Apr 11, 2003 at 14:58 UTC | |
|
Re: Re: Replacing parts of a string
by spiderbo (Sexton) on Apr 15, 2003 at 08:23 UTC | |
by tachyon (Chancellor) on Apr 16, 2003 at 03:15 UTC |