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

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -