regex - Gradle/Java replace text -
is possible use regex convert urls in css files in way demonstrated below? don't want hardcode font names.
from:
url('../fonts/glyphiconshalflings-regular.eot?#iefix') format('embedded-opentype')
to:
url("#{resource['css:../fonts/glyphiconshalflings-regular.eot']}?#iefix") format('embedded-opentype')
and have:
task fixcssresources << { filetree cssfiles = filetree("src/main/webapp") { include "**/*.css" } cssfiles.each { file cssfile -> string content = cssfile.gettext("utf-8") // here? cssfile.write(content, "utf-8") } }
assuming want format url(something)
, should want:
string regex = "url\\('([^']*?\\.(eot|ttf|fnt))(.*?)'\\)"; // font file formats^ content = content.replaceall(regex, "url(\"#{resource['css:$1']}$3\")");
edit: forgot escape characters.
Comments
Post a Comment