%r{ # Use %r{} instead of /…/ so we don't have to escape slashes
\A # Make sure we start at the front of the string
(?!rails_admin) # NOW ensure we can't see rails_admin from here
([^_/]|/[^_]) # (I have no idea what your logic is here)
([^/]*) # the file name
\.s?css # the extension
\z # Finish with the very end of the string
}x # Extended mode allows us to put spaces and comments in here
Rubyの正規表現では、文字列ではなく行の開始/終了^
と一致するため、通常は代わりにを使用することをお勧めします。$
\A
\z
編集:これは、任意のパスを許可する変更されたバージョンです。
%r{ # Use %r{} instead of /…/ so we don't have to escape slashes
\A # Make sure we start at the front of the string
(?!rails_admin) # NOW ensure we can't see rails_admin from here
(.+/)? # Anything up to and including a slash, optionally
([^/]*) # the file name
\.s?css # the extension
\z # Finish with the very end of the string
}x # Extended mode allows us to put spaces and comments in here
編集とコメントに基づいて、一致する正規表現は次のとおりです。
- .cssまたは.scssで終わるファイル
- ただし、パスがで始まる場合はそうではありません
rails_admin
- ファイル名がアンダースコアで始まる場合ではありません
%r{ # Use %r{} instead of /…/ so we don't have to escape slashes
\A # Make sure we start at the front of the string
(?!rails_admin) # NOW ensure we can't see rails_admin from here
(?:.+/)? # Anything up to and including a slash, optionally (not saved)
(?!_) # Make sure that we can't see an underscore immediately ahead
([^/]*) # the file name, captured
\.s?css # the extension
\z # Finish with the very end of the string
}x # Extended mode allows us to put spaces and comments in here