if (/^$date\s+(.+)/)

A

April

{
printf "%2d. ", $count;
print "$1\n";
}

what would be true for /^$date\s+(.+)/? \s+ matches one or more white
spaces, and (.+) matches the rest?
 
T

Tim Greer

April said:
{
printf "%2d. ", $count;
print "$1\n";
}

^^^^^^^^^^

Is the above supposed to relate to your question?
what would be true for /^$date\s+(.+)/? \s+ matches one or more white
spaces, and (.+) matches the rest?

..+ matches anything (one or more characters) after the start of the line
^ and whatever $date is, one or more white spaces and then captures
whatever follows it. You might want to be more specific if you want to
match up to the end of the line $ or include new lines, or only match
up to a certain length or character, etc. So, yes and no, depending.
 
A

April

^^^^^^^^^^

Is the above supposed to relate to your question?


.+ matches anything (one or more characters) after the start of the line
^ and whatever $date is, one or more white spaces and then captures
whatever follows it.  You might want to be more specific if you want to
match up to the end of the line $ or include new lines, or only match
up to a certain length or character, etc.  So, yes and no, depending.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!

thanks Tim .. then what would be true here, something started with
$date exists?
 
A

April

It's probably cut and pasted from the assignment sheet.

--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
        If failure had no penalty success would not be a prize (T..  Pratchett)
Company Details:http://www.fujitsu-siemens.com/imprint.html

yes, that is the block to be executed, depending on the if test
result ..
 
J

Jürgen Exner

April said:
{
printf "%2d. ", $count;
print "$1\n";
}
???

what would be true for /^$date\s+(.+)/? \

You question is confusing. Did you mean to ask: Which strings are
matched by that RE?

Answer to that question:
Any string, that
- starts with
- whatever is matched by the RE stored in $date
and then
\s+ matches one or more white
-has at least one white space
spaces, and (.+) matches the rest?
- and then at least one other character

jue
 
A

April

That depends on the current line ($_) and the value of $date.

You need to provide more info if you expect to receive any help.  

I'm looking for the meaning of that test, not an actual answer in the
program context.
 
A

April

You question is confusing. Did you mean to ask: Which strings are
matched by that RE?

Answer to that question:
Any string, that
- starts with
- whatever is matched by the RE stored in $date
and then


-has at least one white space


- and then at least one other character

jue

my question should be restated as what makes the if test true, if (/^
$date\s+(.+)/)?
 
J

Jürgen Exner

if (/^$date\s+(.+)/)
my question should be restated as what makes the if test true, if (/^
$date\s+(.+)/)?

Ok, that is easy. The condition is true if and only if the regular
expression /^$date\s+(.+)/ matches the text content of $_.

jue
 
A

April

                if (/^$date\s+(.+)/)


Ok, that is easy. The condition is true if and only if  the regular
expression /^$date\s+(.+)/ matches the text content of $_.

jue

k thank you Jue and everyone I think with this and the explanation of
the re/pattern, I'm all set and thanks again.
 
S

sln

{
printf "%2d. ", $count;
print "$1\n";
}

what would be true for /^$date\s+(.+)/? \s+ matches one or more white
spaces, and (.+) matches the rest?

Yes, is date variable? It is part of the regex.
What is the result if

$date = "12/25/2008";
$_ = "12/25/2008
is an important date
on the calendar.";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top