outaTiME / grunt-replace

Replace text patterns with applause.
MIT License
411 stars 47 forks source link

fires once? #88

Closed nicothin closed 3 years ago

nicothin commented 8 years ago

http://regexr.com/3cg68 — my regex (works the way I expect that) in my gruntfile:

replace: {
      clean_html: {
        options: {
          patterns: [
            {
              match: /<script>([\s\S]*)?(\/\*[\s\S]*?\*\/)([\s\S]*)?<\/script>/gm,
              replacement: '<script>$1$3<\/script>'
            }
          ]
        },
        files: [
          {
            expand: true,
            src: ['build/*.html']
          }
        ]
      },
    },

my markings is the same as in the example online link in two fragments of code that need to be replaced, but the change takes place only in one (second) if you write in gruntfile:

replace: {
      clean_html: {
        options: {
          patterns: [
            {
              match: /<script>([\s\S]*)?(\/\*[\s\S]*?\*\/)([\s\S]*)?<\/script>/gm,
              replacement: '<script>$1$3<\/script>'
            },
            {
              match: /<script>([\s\S]*)?(\/\*[\s\S]*?\*\/)([\s\S]*)?<\/script>/gm,
              replacement: '<script>$1$3<\/script>'
            }
          ]
        },
        files: [
          {
            expand: true,
            src: ['build/*.html']
          }
        ]
      },
    },

the two changes occur

Q: what am I doing wrong? what to write, to not have to duplicate the pattern?

outaTiME commented 8 years ago

Hi pal, sorry for delay ... i will check ...

thks !!!

outaTiME commented 3 years ago

Sorry for the long wait, the patterns are executed one after another on the same source file, and from what I see you need a replacement for a replacement, the best thing is to chain the tasks together, closing it for now.