Search the web
Sign In
New User? Sign Up
Perl_Official · Perl . CGI . Shell script
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Backreference question   Message List  
Reply | Forward Message #2038 of 2062 |
Example string
$Data=":2-Name1:4-Name2:3-Name3:1-Name4:";

I need to get the following info
:4-Name2:

But All I can search with is
:4-anything:
In other words I know it starts with :4-
then it has a name in the middle
and ends with the next :

my guess is
$Info = ($Data =~ /(:4-*:)/);
$Info if the var assigned the value sought.
$Data is the string I am searching
:4- and the last : are know
* are the unknown characters, if any

here is the program
#!/usr/bin/perl
use strict ;

my $Data=":2-Name1:4-Name2:3-Name3:1-Name4:";
my $Info = ($Data =~ /(:4-*:)/);
print ">$Info<";




Fri Aug 31, 2007 3:24 am

luinrandir
Offline Offline
Send Email Send Email

Forward
Message #2038 of 2062 |
Expand Messages Author Sort by Date

Example string $Data=":2-Name1:4-Name2:3-Name3:1-Name4:"; I need to get the following info ... But All I can search with is ... In other words I know it starts...
Luinrandir Hernsen
luinrandir
Offline Send Email
Aug 31, 2007
5:00 pm

The main problem with your attempted solution is that .* is greedy. This means that the colon it would find is the last one on the line. Greedy means that .*...
Glen Brydon
glen_brydon
Offline Send Email
Sep 1, 2007
12:22 am

Thanks for the responce Glen If you going to ask why I don't use MySql... I have not had time to figure out who to use it... I am just now begining to grasp...
Lou Hernsen
luinrandir
Offline Send Email
Sep 4, 2007
5:27 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help