Skip to content

Commit 1cd34e2

Browse files
committed
Merge pull request #2 from purescript/regex-replace
Regex replacing
2 parents 12cd06d + 434b159 commit 1cd34e2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Data/String/Regex.purs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,26 @@ foreign import match
2323
\ };\
2424
\}" :: Regex -> String -> [String]
2525

26-
foreign import replaceR
27-
"function replaceR(r) {\
26+
foreign import replace
27+
"function replace(r) {\
2828
\ return function(s1) {\
2929
\ return function(s2) {\
3030
\ return s2.replace(r, s1);\
3131
\ };\
3232
\ };\
3333
\}" :: Regex -> String -> String -> String
3434

35+
foreign import replace'
36+
"function replace$prime(r) {\
37+
\ return function(f) {\
38+
\ return function(s2) {\
39+
\ return s2.replace(r, function (match) {\
40+
\ return f(match)(Array.prototype.splice.call(arguments, 1, arguments.length - 3));\
41+
\ });\
42+
\ };\
43+
\ };\
44+
\}" :: Regex -> (String -> [String] -> String) -> String -> String
45+
3546
foreign import search
3647
"function search(r) {\
3748
\ return function (s) {\

0 commit comments

Comments
 (0)