Ruby正则表达式忽略了#character

时间:2016-06-02 22:11:46

标签: ruby regex

我在Ruby中有以下字符串

"  # config.autoload_paths = $(lib)\n"

当我使用以下

尝试正则表达式匹配时,我得到一个匹配
/\s*config.autoload_paths\s*=/

我不确定为什么这是匹配的。由于字符串中的/\s*c字符,我期望正则表达式前面的#部分导致匹配失败。有什么想法可以匹配吗?

1 个答案:

答案 0 :(得分:1)

$font = "./Verdana.ttf"; $fontSize = 24; // note: double your original value. $img = imagecreatetruecolor(1200, 1200); // note: double your original values. imagealphablending($img, false); imagesavealpha($img, true); $transparent = imagecolorallocatealpha($img, 255, 255, 255, 127); $grey = imagecolorallocate($img, 127, 127, 127); imagefilledrectangle($img, 0, 0, $imageX, $imageY, $grey); imagettftext($img, $fontSize, 0, $text_posX, $text_posY, -$transparent, $font, "This is a transparent text"); $dest = imagecreatetruecolor(600, 600); imagealphablending($dest, false); imagesavealpha($dest, true); imagecopyresampled($dest, $img, 0, 0, 0, 0, 600, 600, 1200, 1200); header('Content-Type: image/png'); imagepng($dest); 表示任意数量的空格后跟\s*c 。如果您想从该行的开头创建它,请添加一个锚:c

没有锚点的演示:here

^

使用锚点进行演示:there