On 28/07/2010, at 1:03, Martin Barry wrote:
You could get crazy and try to do this in a single regex but two
stage is
clearer. e.g.
sed -e 's/&pg=[^&]*//g' -e 's/?pg=[^&]*&/?/'
Now you have 2 problems.
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription in
Call me crazy!
s/(&|?)pg=[^&]*/\1/
(correct escaping of & and ? left as an exercise for someone actually using
this :)
On 27 July 2010 08:03, Martin Barry wrote:
> Sorry to bring up an old thread but I just had to comment on this...
>
> $quoted_author = "Jamie Wilkinson" ;
> >
> > Try:
> >
> >
Sorry to bring up an old thread but I just had to comment on this...
$quoted_author = "Jamie Wilkinson" ;
>
> Try:
>
> /&pg=[^&]*/
>
> match zero or more of the character class that is not an ampersand.
Except there is nothing stopping the variables being reordered, no? So you
may need to matc
Perhaps this is the time for me to ask: does anyone know a way for grep
or awk to extract from a text file any sequence of up to, say, six words
that begins and ends with an initially-capitalised word -- whether or
not it is part of a larger matching sequence?
So if the input text was:
"Sall
Thanks Nick, What I didn't know was that ^ inside brackets [] means "not". I was still
reading ^ as "beginning of string".
That will be very very useful in future.
Thanks
Pete
Nick Andrew wrote:
On Wed, Jul 14, 2010 at 01:27:13PM +1000, Peter Rundle wrote:
I don't really understand how the
On 14/07/2010, at 13:27, Peter Rundle wrote:
P.S I didn't understand Lindsay's question about doing the replace.
I'm replacing the arg with nothing, I.E I just want to remove the
"pg=" argument from the string.
Didn't know what you were replacing your match with, was just curious
abou
On Wed, Jul 14, 2010 at 01:27:13PM +1000, Peter Rundle wrote:
> I don't really understand how the [^&] followed by the * works but it does.
"any character which is not an ampersand" repeated zero or more times.
So it matches
()
()&
(a)
(a)&
(aaa...)
(aaa...)&
Where the stuff inside () is what's
Thanks Jamie (and others),
That works a treat.
I would have tried
/&pg=*[^&]/
which of course would have matched all &ersands up until the last taking out
more than one argument.
I don't really understand how the [^&] followed by the * works but it does.
Thanks
Pete
P.S I didn't understand
I don't see the problem with my approach; the match will terminate when it
sees the second ampersand, without consuming it.
On 13 July 2010 19:01, Ken Foskey wrote:
> > "/&pg=.*&/"
>
> >But also I think & is a special char (no?) that means "put the matched bit
> back", though is that only
> "/&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).
Yes the ampersand is special, it represents the complete matched string on
the replace.
s/&pg=.*
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
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 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 operato
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 wrote:
> Try:
>
> /&pg=[^&]*/
>
> match zero or more
Try:
/&pg=[^&]*/
match zero or more of the character class that is not an ampersand.
On 13 July 2010 17:21, Peter Rundle 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
>
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=som
15 matches
Mail list logo