Why does this ruby-regular expression not match this string?

x = "output/file.zip"

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

returns nil. There is something wrong with avoiding the period, but I cannot understand.

+3
source share
1 answer

.usually means "any character" in a regular expression. Try this .*, which means " .repeats zero or more times":

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

Works great for me.

+5
source

Source: https://habr.com/ru/post/1793132/


All Articles