Regex Tester

Dan's Tools

Replace script tag to amp-iframe


Comments


Top Regular Expressions

Cheat Sheet

Character classes
. any character except newline
\w \d \s word, digit, whitespace
\W \D \S not word, digit, whitespace
[abc] any of a, b, or c
[^abc] not a, b, or c
[a-g] character between a & g
Anchors
^abc$ start / end of the string
\b word boundary
Escaped characters
\. \* \\ escaped special characters
\t \n \r tab, linefeed, carriage return
\u00A9 unicode escaped ©
Groups & Lookaround
(abc) capture group
\1 backreference to group #1
(?:abc) non-capturing group
(?=abc) positive lookahead
(?!abc) negative lookahead
Quantifiers & Alternation
a* a+ a? 0 or more, 1 or more, 0 or 1
a{5} a{2,} exactly five, two or more
a{1,3} between one & three
a+? a{2,}? match as few as possible
ab|cd match ab or cd
)/igm"; var t = dan.el("#cheatsheet"); t.style.display = "none", Docs.getItem("cheatsheet").desc = t.innerHTML, e.setExpression(DocView.DEFAULT_EXPRESSION).setSubstitution(DocView.DEFAULT_SUBSTITUTION), e.resetHistory(); var o = new LibView(dan.el("#libview"), Docs.content.library); this.libView = o, o.docView = e, e.libView = o, ExpressionModel.docView = e, ExpressionModel.saveState(), Settings.trackVisit(), Settings.cleanSaveTokens(), this.navigate() } }, i.handleHistoryChange = function() { this.navigate() }, i.navigate = function() { var e = document.location.toString(), i = /[\/#\?]([\w\d]+)$/gi.exec(e), t = null; if (i && (t = i[1]), ExpressionModel.id != dan.idToNumber(t) + "") if (dan.isIDValid(t)) { var o = this; ServerModel.getPatternByID(t).then(function(e) { ExpressionModel.setLastSave(e); var i = dan.parsePattern(e.pattern); o.docView.populateAll(i.ex, i.flags, e.content, e.replace) }, function() { BrowserHistory.go() }) } else BrowserHistory.go() }, i.showVideo = function(e) { var i = null, t = dan.el(".video"); e !== !1 ? (dan.removeClass(t, "hidden"), t.addEventListener("click", this.handleVideoCloseProxy), i = "playVideo", this._ctaAnimation.stop = !0) : (dan.addClass(t, "hidden"), t.removeEventListener("click", this.handleVideoCloseProxy), i = "pauseVideo"); var o = dan.el(".video iframe").contentWindow; o.postMessage('{"event":"command","func":"' + i + '","args":""}', "*") }, i.handleVideoClick = function() { this.showVideo(!1) }, window.RegExr = e }(), WebFont.load({ google: { families: ["Source Code Pro:400,700", "Cabin:400,700"], fontinactive: function() { WebFont.load({ custom: { families: ["Source Code Pro:400,700", "Cabin:400,700"], urls: ["css/fontFallback.css"] } }) } }, active: function() { window.regexr = new window.RegExr } });