Reputation: 13
I have a grunt contrib copy task that will copy a file correctly, but I would also like to change a file path that is repeated through out the the content of the file that is being copied. I do not have a lot of experience with javascript regular expressions, my only success so far is replacing one word with another word.
options: {
process: function (content, srcpath) {
return content.replace((/...\/resources\/fonts//gi,""));
}
}
I would like to replace the string "../resources/fonts" with an empty string "".
Upvotes: 1
Views: 2989
Reputation: 933
Suggested code is not working with my code below. However, regex seems correct.
copy: {
main: {
options: {
process: function (content, srcpath) {
return content.replace((/dist\//gi,""));
}
},
files: [
{
expand: true,
src: ['*.html'],
dest: '<%= distDir %>/',
filter: 'isFile'
}
]
},
},
Upvotes: 0
Reputation: 11403
If you want to replace "../resources/fonts" then the regexp you need is:
/\.\.\/resources\/fonts/gi
(escape the dots and slashes)
Upvotes: 2