what does the regular expression $$ evaluate to?
That can depend on the exact type of REs in use. In the commonly-used POSIX basic REs, $ means, basically, "end of line". So this would match a line followed by an empty line.
It just depends on the underlying regex engine. In vim it would match a dollar sign at the end of line, for example. I'd guess that Posix would require the engine to match the same as '$' since that literal has 0 length as Tomalak pointed out.
It depends on the underlying regex engine. But in the .Net framework System.Text.RegularExpressions.Regex class, $ within regular expressions specifies that the match must occur at the end of the string, before \n at the end of the string, or at the end of the line, so $$ will match everything!
($$ has another meaning in replacement patterns, which substitutes a single "$" literal.)
Normally is a matcher for end-of-line but this depend on which language are you using. Without this specific information is difficult to answer.
BTW, in csh means the process number. It is not a regular expression.
Luis
That construct is unlikely to occur except in languages that allow variable interpolation in the regex. In that case it most likely will match the process id of the current process (since $$
is generally a variable that holds the process id).
in Perl, embedding $$
into a regular expression will result in the PID of the perl process being inserted
# Suppose perl has a PID of 5432
my $str1 = "some";
my $str2 = "5432";
print "1 match: $str1" if $str1 =~ /^$$/;
print "2 match: $str2" if $str2 =~ /^$$/;
Output:
2 match: 5432
Inserting a single $
will match the end of line.
It depends on the programming language and regexp engine.
- In Perl,
/$$/
matches the PID (process id) of the current process (see more in dsm's answer). - In Ruby, both
/$$/
and/$/
match the empty string before the first newline, or the end of the string if there are no newlines in the string. - In Python, both
re.search('$$', s)
andre.search('$', s)
match the empty string before the last newline, or the end of the string if there are no newlines in the string. - (Other languages or regexp engines may behave differently.)
Please note that the flags (usually the s
and the m
flags) associated with the regexp affect what $
matches. The items above use the default flags.