D
Davy
Hi,
Is ^$ mean a NULL line?
Best regards,
Davy
Is ^$ mean a NULL line?
Best regards,
Davy
Is ^$ mean a NULL line?
"lines with no characters in them"
A slightly shorter answer to the original question would have been "Yes"Mirco said:Thus spoke Mirco Wahab (on 2006-06-20 13:25):
A made up example of how you would use it:
use strict;
use warnings;
my $count = 0;
my $text= <<END_OF_TEXT;
A Line with something in it
two empty lines above!
(done)
END_OF_TEXT
print "empty line " . ++$count . " found\n"
for $text =~ /^$/gm; # <== here we go
Regards
Mirco
Is ^$ mean a NULL line?
Davy said:Is ^$ mean a NULL line?
Nick of course said:Mirco Wahab wrote:
A slightly shorter answer to the original question would have been "Yes"
Tad said:Nick of course said:Mirco Wahab wrote:
[snip full-quote]
A slightly shorter answer to the original question would have been "Yes"
That would have been a slightly shorter *wrong* answer.
(Since it will match when the string is "\n".)
The original (poorly phrased) question was:
Is ^$ mean a NULL line?
The OP didn't say where these characters are used. I'll guess they
are used with the pattern match operator.
What does "NULL line" mean?
I assume it means the "empty string" (in which case it cannot be
a "line" since it has no newline character).
So if a boolean response is required then "No" would be the accurate answer.
A more helpful answer would be:
/^$/ matches the empty string, or the 1-char long string where
the 1 char is a newline.
Tad McClellan wrote:
I don't disagree with your definition Tadd,
s/Tadd/Tad/;
but I'm curious as to what
meaning, other than "at the beginning of the (string | line) match the
end of (string | line)" "^$" might have? Don't meta-characters remain
remain meta-characters where ever they are,
I don't disagree with your definition Tadd,
s/Tadd/Tad/;
but I'm curious as to what
meaning, other than "at the beginning of the (string | line) match the
end of (string | line)" "^$" might have? Don't meta-characters remain
remain meta-characters where ever they are,
No, they don't.
What the syntax means depends on what language the characters are in.
If you had instead said:
Is /^$/ mean a NULL line?
Then we would have known that the language the metacharacters appear
in is the regex language. (regex language)
But if you had said:
Is [^$] mean a NULL line?
Then the answer would have been: No, it matches any single character
that is not a dollar sign. (character class language)
And if you had said:
Is $vector^$mask mean a NULL line?
Then the answer would have been: No, it is a bitwise exclusive-or
and the sigil of a variable. (Perl language)
Taking just the caret (^) character, it has 3 meanings in 3
different languages:
Perl: bitwise exclusive-or
regex: beginning of string
char class: negates the class
Apart from that, even in the *same* language the same character
can have different meta-meanings. Take curly braces in Perl for
example: part of a hash slice, code block, anonymous hash
constructor, variable name delimiter, part of a hash access...
So, we cannot talk about Perl symbols without knowing a bit about
the context where the symbols appear, hence the encouragement to
post Real Perl Code in the Posting Guidelines.
Have you seen the Posting Guidelines that are posted here frequently?
Thank you Tadd, I've read your guidlines, many times in fact. Notice
that I never post in your moderated group?
You seem to be back to over-thinking the question. The question didn't
have anything to do with character classes or an XOR! Just two
charactors ^ followed by $.
Please learn the difference between moderator in a moderated group and
ass in a new group before responding.
You seem to be back to over-thinking the question. The question
didn't have anything to do with character classes or an XOR!
Just two charactors ^ followed by $.
Thank you Tadd,
You seem to be back to over-thinking the question.
The question didn't
have anything to do with character classes or an XOR!
Just two
charactors ^ followed by $.
Sorry life doesn't always flow in the vein you chose.
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.