开发者

Why won't this ruby regex match this string?

开发者 https://www.devze.com 2023-02-11 18:31 出处:网络
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. Tr
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

精彩评论

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

关注公众号