On Sat, 12 Apr 2003 19:01:28 +0000, you wrote:

>Got a quick (simple??) question. I can't seem to find an example of how to
>do it!!
>
>I have the following string:
>
>    $test = "my brother is not ok today and i want milk for food"
>
>I'd like to be able to place "is not ok today" in $1 and "want milk" in $2.
>Should be pretty easy, you simply start the search on "my brother", place
>"is not ok today" in $1, skip the "and", place "want milk" in $2 and you're
>done....
>
>    sort of like ->    $test =~ /my brother([ ])..../
>    the result would be placed in $1, and $2....
>
>I'm trying to get a better understanding as to how one can quickly get to a
>group of chars that match a given term, do something, and then search for a
>subsequesnt group of chars....
>
>All the examples I see use a single char as opposed to a group. In other
>words, how does one put a group of chars in a [] such that they will be used
>for an exact match???

I'm not terribly clear on what you're after.  I *think* you want

$test =~ /^my brother (.+) and i (.+) for food$/;

The ".+" matches one or more characters other than newline.  The "^"
requires the match to start at the beginning of the string, and the "$"
requires the match to go to the end of the string.

You can also put any arbitrary list of characters in [], such as

[A-Z,.;]

This matches one uppercase letter, comma, period, or semicolon.  As you
can see, ranges can be used to save typing.  There is plenty of
information available if you use the command "perldoc perlre"; you might
also have "perldoc perlretut" as well.

-- 
Eric Amick
Columbia, MD

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to