grunt-text-replace icon indicating copy to clipboard operation
grunt-text-replace copied to clipboard

Regexp not matching.

Open karimbeyrouti opened this issue 10 years ago • 5 comments

Hello there,

For some reason my regexp search and replace is no longer matching my selection - not sure which version this started happening with, however it used to work just fine. Nothing changed my side. ( I am using latest grunt / grunt-cli / replace ) .

Here is my replace grunt task:

    replace: {
        removeextend: {
            src: ['bin/js/**/*.js'],
            overwrite: true,                 // overwrite matched source files
            replacements: [{
                from: /var __extends[\W\S\D]*__\(\);\s};/g,
                to: ""
            }]
        }
    },...

and an example file: http://kurst.co.uk/transfer/JSONLoader.js

Here is the Regex in action: http://www.regexr.com/39u9o

Not sure why this stopped working - that query used to work. Any insight into why this stopped working would be welcome.

Thank you for your time.

karimbeyrouti avatar Nov 19 '14 11:11 karimbeyrouti

Hi Karim, thanks for raising this. Nothing's changed about the plugin for a good while, so not sure what might be going wrong. FYI I'm pretty stacked at the moment, so can't look at this immediately, but will try when I can. If you get any further with investigations let me know.

Thanks again,

Jonathan

yoniholmes avatar Nov 19 '14 20:11 yoniholmes

Thank you Jonathan, currently looking into it - and not finding anything obvious. Will let you know if I get to the bottom of this.

karimbeyrouti avatar Nov 20 '14 10:11 karimbeyrouti

Interestingly enough - this looks like a windows issue. The same script works on OSX - with same version of Node & Grunt ...

karimbeyrouti avatar Nov 21 '14 13:11 karimbeyrouti

I had the same issue and it turned out to be that my RegExp was trying to match newlines in a way that worked in OS X but didn't in Windows.

gabrielmaldi avatar Apr 29 '15 05:04 gabrielmaldi

I'm just playing around with this now, and it seems the plugin isn't matching spaces properly. I'm trying to read a json file, manifest.json, using a function call and a grunt.log to see what's going on (it would be great if this plugin outputted what was changed!), and when I try and match \"version\" it works fine, but when I try and match \"version\" with a space it does nothing.

Rainbowlemon avatar Feb 10 '17 13:02 Rainbowlemon