开发者

Why won't this ruby regex match this string?

x = "output/file.zip"

x =~ /output\/.\../

returns n开发者_如何学Cil. There is something wrong with escaping the period, but I can't figure it out.


. usually means "any character" in regex. Try .*, which means ". repeated zero or more times":

x =~ /output\/.*\..*/

Works fine for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜