Re: [ubuntu-uk] Quick Perl question...

2010-07-12 Thread Jon Spriggs
I'm not very^h any good with Regex, but try putting ()'s around what you
want to search for. Also, try out rubular.com to experiment without needing
to drop out of your editor and running something to test it.

All the best,

-- 
Jon "TheNiceGuy" Spriggs

On 12 Jul 2010 21:13, "LeeGroups"  wrote:

I'm having a bit of an issue with a Perl script on my Ubuntu server at
home (can you see what I did there :)...

The line in question is this...

$solar_info =~ s/<\/solar>.*/,/;

 From my tinkerings, this should find the string  in the string
$solar_info, and then remove it and any number of following characters
(the .*) and then replace them with a ",".
Except that it doesn't. It hacks out the  and replaces it with a
, but leaves the rest of the string intact... Much to my annoyance... :|

Any clues?

Cheers,
Lee


--
ubuntu-uk@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk
https://wiki.ubuntu.com/UKTeam/
-- 
ubuntu-uk@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk
https://wiki.ubuntu.com/UKTeam/


Re: [ubuntu-uk] Quick Perl question...

2010-07-12 Thread Colin Law
On 12 July 2010 21:12, LeeGroups  wrote:
> I'm having a bit of an issue with a Perl script on my Ubuntu server at
> home (can you see what I did there :)...
>
> The line in question is this...
>
> $solar_info =~ s/<\/solar>.*/,/;
>
>  From my tinkerings, this should find the string  in the string
> $solar_info, and then remove it and any number of following characters
> (the .*) and then replace them with a ",".
> Except that it doesn't. It hacks out the  and replaces it with a
> , but leaves the rest of the string intact... Much to my annoyance... :|
>
> Any clues?

Is there a setting for perl reg exps to tell it whether to use the
shortest string that matches or the longest that matches?  Possibly
you have that set to the shortest so the match is satisfied without
including all the trailing chars.

Colin

-- 
ubuntu-uk@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-uk
https://wiki.ubuntu.com/UKTeam/