Skip to content

Commit

Permalink
Merge pull request #2 from purescript/regex-replace
Browse files Browse the repository at this point in the history
Regex replacing
  • Loading branch information
paf31 committed May 4, 2014
2 parents 12cd06d + 434b159 commit 1cd34e2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Data/String/Regex.purs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,26 @@ foreign import match
\ };\
\}" :: Regex -> String -> [String]

foreign import replaceR
"function replaceR(r) {\
foreign import replace
"function replace(r) {\
\ return function(s1) {\
\ return function(s2) {\
\ return s2.replace(r, s1);\
\ };\
\ };\
\}" :: Regex -> String -> String -> String

foreign import replace'
"function replace$prime(r) {\
\ return function(f) {\
\ return function(s2) {\
\ return s2.replace(r, function (match) {\
\ return f(match)(Array.prototype.splice.call(arguments, 1, arguments.length - 3));\
\ });\
\ };\
\ };\
\}" :: Regex -> (String -> [String] -> String) -> String -> String

foreign import search
"function search(r) {\
\ return function (s) {\
Expand Down

0 comments on commit 1cd34e2

Please sign in to comment.