diff --git a/src/compiler/parser/filter-parser.js b/src/compiler/parser/filter-parser.js
index 427563a7..8e0fb0cd 100644
--- a/src/compiler/parser/filter-parser.js
+++ b/src/compiler/parser/filter-parser.js
@@ -4,6 +4,7 @@ export function parseFilters (exp: string): string {
let inSingle = false
let inDouble = false
let inTemplateString = false
+ let inRegex = false
let curly = 0
let square = 0
let paren = 0
@@ -14,14 +15,13 @@ export function parseFilters (exp: string): string {
prev = c
c = exp.charCodeAt(i)
if (inSingle) {
- // check single quote
- if (c === 0x27 && prev !== 0x5C) inSingle = !inSingle
+ if (c === 0x27 && prev !== 0x5C) inSingle = false
} else if (inDouble) {
- // check double quote
- if (c === 0x22 && prev !== 0x5C) inDouble = !inDouble
+ if (c === 0x22 && prev !== 0x5C) inDouble = false
} else if (inTemplateString) {
- // check template literal
- if (c === 0x60 && prev !== 0x5C) inTemplateString = !inTemplateString
+ if (c === 0x60 && prev !== 0x5C) inTemplateString = false
+ } else if (inRegex) {
+ if (c === 0x2f && prev !== 0x5C) inRegex = false
} else if (
c === 0x7C && // pipe
exp.charCodeAt(i + 1) !== 0x7C &&
@@ -40,6 +40,7 @@ export function parseFilters (exp: string): string {
case 0x22: inDouble = true; break // "
case 0x27: inSingle = true; break // '
case 0x60: inTemplateString = true; break // `
+ case 0x2f: inRegex = true; break // /
case 0x28: paren++; break // (
case 0x29: paren--; break // )
case 0x5B: square++; break // [
diff --git a/test/unit/features/filter/filter.spec.js b/test/unit/features/filter/filter.spec.js
index 14d58cb8..98e0630e 100644
--- a/test/unit/features/filter/filter.spec.js
+++ b/test/unit/features/filter/filter.spec.js
@@ -54,6 +54,21 @@ describe('Filters', () => {
expect(vm.$refs.bar).toBe(vm.$el)
})
+ it('handle regex with pipe', () => {
+ const vm = new Vue({
+ template: `