-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from zydmayday/replace
add method replace
- Loading branch information
Showing
4 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import re | ||
|
||
from .private._curry3 import _curry3 | ||
|
||
replace = _curry3(re.sub) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
import unittest | ||
|
||
import ramda as R | ||
|
||
""" | ||
https://github.com/ramda/ramda/blob/master/test/replace.js | ||
""" | ||
|
||
|
||
class TestReplace(unittest.TestCase): | ||
def test_replaces_substrings_of_the_input_string(self): | ||
self.assertEqual('one two three', R.replace('1', 'one', '1 two three')) | ||
|
||
def test_replaces_regex_matches_of_the_input_string(self): | ||
self.assertEqual('num num three', R.replace(r'\d+', 'num', '1 2 three')) | ||
|
||
def test_replaces_curry(self): | ||
self.assertEqual('num num three', R.replace(r'\d+')('num')('1 2 three')) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |