Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] regular expression help

Expand Messages
  • Luca Ferrari
    On Thursday 05 August 2004 13:41 Luca Ferrari s cat walking on the keyboard ... Hi guys, thanks everybody for the help. The solution I adopted is $string =~
    Message 1 of 13 , Aug 5 7:15 AM
    • 0 Attachment
      On Thursday 05 August 2004 13:41 Luca Ferrari's cat walking on the keyboard
      wrote:

      > Hi,
      > supposing I've got a string like the following:
      > a.b.c.d.e.f
      > and that I'd like to keep only the first characters before the first
      > '.' (e.g., 'a'), why the following is not working?
      >
      > $string =~ s/^(.+)\.(.*)/$1/;
      >
      > Applied to the above example string it gives me back only 'f'. Any
      > explanation?
      >

      Hi guys,
      thanks everybody for the help.
      The solution I adopted is
      $string =~ s/^(.+?)\.(.*)/$1/;

      I know that I could use split, but since perl has a regexp engine why don't
      use it?

      Thanks everybody,
      Luca

      --
      Luca Ferrari,
      fluca1978@...
    Your message has been successfully submitted and would be delivered to recipients shortly.