MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / unescapeFormat

Function unescapeFormat

tests/test_code/js/moment/moment.js:806–820  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

804
805 // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
806 function unescapeFormat(s) {
807 return regexEscape(
808 s
809 .replace('\\', '')
810 .replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (
811 matched,
812 p1,
813 p2,
814 p3,
815 p4
816 ) {
817 return p1 || p2 || p3 || p4;
818 })
819 );
820 }
821
822 function regexEscape(s) {
823 return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');

Callers 1

getParseRegexForTokenFunction · 0.85

Calls 1

regexEscapeFunction · 0.85

Tested by

no test coverage detected