how about using a slightly different approach with split @input = split /\&/;
$input[0] should now be pg=something, $input[1] will be the args=somthingelse so you can trivially match, modify and print this to your output, whether or not it has extra arguments. On Wed, Jul 14, 2010 at 11:24 AM, Jamie Wilkinson <[email protected]>wrote: > I'd use a global search and replace command, if it were me, and I was using > sed: sed -ie 's/&pg=[^&]//g' lindsay.html > > On 13 July 2010 18:13, Lindsay Holmwood <[email protected]> wrote: > > > Now you've got the search, I'm curious how you are going to do the > replace. > > > > Is the Perlism to just use the substitute operator, or split on the > > pattern, iterate through the array, and join again? > > > > Lindsay > > > > On 14 July 2010 10:30, Jamie Wilkinson <[email protected]> wrote: > > > Try: > > > > > > /&pg=[^&]*/ > > > > > > match zero or more of the character class that is not an ampersand. > > > > > > On 13 July 2010 17:21, Peter Rundle <[email protected]> wrote: > > > > > >> Hi Sluggers, > > >> > > >> I'm sure some of you genii have a real quick solution to this. > > >> > > >> I'm trying to find and replace and argument in a url. The url is of > the > > >> form > > >> > > >> &pg=something&arg=somethingelse > > >> > > >> > > >> I want to take out the &pg=something but the "&arg=" may or may not be > > >> there. How do I say match the &pg=something up to but not including > the > > next > > >> & (which may or may not be there). > > >> > > >> "/&pg=.*&/" > > >> > > >> But also I think & is a special char (no?) that means "put the matched > > bit > > >> back", though is that only on the replace side? (my question relates > > >> strictly to the matching side). > > >> > > >> > > >> TIA's > > >> > > >> Pete > > >> > > >> > > >> -- > > >> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ > > >> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html > > >> > > > -- > > > SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ > > > Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html > > > > > > > > > > > -- > > w: http://holmwood.id.au/~lindsay/ > > t: @auxesis > > -- > > SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ > > Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html > > > -- > SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ > Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html > -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
