fixedpoint.jp - /^+/




/^+/

正規表現の /^+/ に対して各処理系がどのように振る舞うか;

$ sed --version
GNU sed version 4.1.5
(snip)
$ echo '+' | sed -e 's/^+/-/'
-
$
$ perl --version

This is perl, v5.8.8 built for i486-linux-gnu-thread-multi
(snip)
$ echo '+' | perl -e 'while (<>) {print "$&\n" if (/^+/);}'

$
$ ruby --version
ruby 1.8.6 (2008-03-03 patchlevel 114) [i486-linux]
$ echo '+' | ruby -e 'puts $& if $stdin.read =~ /^+/'
-e:1: invalid regular expression; there's no previous pattern, to which '+' would define cardinality at 2: /^+/
$
$ gosh -V
Gauche scheme interpreter, version 0.8.13 [utf-8,pthreads]
$ echo '+' | gosh -e '(print (rxmatch-substring (#/^+/ (read-line (current-input-port))) 0))'
gosh: "error": stack overrun during matching regexp #/^+/
$

まちまちです。


© 2006-2008 Takeshi Abe