On Thu, Feb 14, 2002 at 04:10:06PM -0600, Russ Foster wrote:
> I have string, something like:
> 
>       $String = "aaa bbb: fffd: sdfsdf qweqd: adfsdf qwcdsfs: qwdq qchuti:
> qwiojd";
> 
> Now, I want to extract everything from the start of the string, up through
> the FIRST colon ":" -- in this case "aaa bbb". My regex looks like this:
> 
>       $String =~ /^(.*):/ ;

As mentioned by a couple of people, the non-greedy version of * is one way
of going about it:

    $String =~ /^(.*?):/;

A faster way, however, is to realize that what you really want is
anything-but-a-colon followed by a colon:

    $String =~ /^([^:]+):/;

Please see perldoc perlretut and perldoc perlre.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to