I am trying to set-up a guardfile for a simple web development project.
I want it to check the HTML files in the current dir, and the CSS files in the ./css/
directory.
I am really new to regular expressions. I have managed to match the HTML files in the current directory with this regexpr ^.+\.html$
.
I need to descend to the directory tree to access ./css/anyfile.css
files.
I've tried this: ^(.+\.html)|(css/.+\.css)$
. I am checking the regular expression with ls | egrep 'regexpr'
, running it at project root.
I only get as result the .html
file.
It seems weird that it doesn't work, because here using this block:
guard 'livereload' do
watch(%r{app/views/.+\.(erb|haml|slim)})
watch(%r{app/helpers/.+\.rb})
watch(%r{public/.+\.(css|js|html)})
watch(%r{config/locales/.+\.yml})
# Rails Assets Pipeline
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html))).*}) { |m| "/assets/#{m[3]}" }
end
it can acess subdirectories such as app
,public
and config
.
You need to escape the forward slash, so your regexp becomes ^(.+\.html)|(css\/.+\.css)$
. You can use http://rubular.com to check if the RegExp is a valid Ruby Regexp.