Skip to content

Commit

Permalink
String.split: Improve documentation
Browse files Browse the repository at this point in the history
- Add more examples
- Fix typo
  • Loading branch information
gasi committed Nov 9, 2022
1 parent 3d3e2f7 commit d3884a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Bugfixes:

Other improvements:

- `split`
- Add more examples.
- Fix typo in documentation.

## [v6.0.1](https://github.com/purescript/purescript-strings/releases/tag/v6.0.1) - 2022-08-16

Bugfixes:
Expand Down
9 changes: 8 additions & 1 deletion src/Data/String/Common.purs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,18 @@ foreign import replace :: Pattern -> Replacement -> String -> String
-- | ```
foreign import replaceAll :: Pattern -> Replacement -> String -> String

-- | Returns the substrings of the second string separated along occurences
-- | Returns the substrings of the second string separated along occurrences
-- | of the first string.
-- |
-- | ```purescript
-- | -- single match
-- | split (Pattern " ") "hello world" == ["hello", "world"]
-- | -- multiple match
-- | split (Pattern " | ") "foo | bar | baz" == ["foo", "bar", "baz"]
-- | -- no match
-- | split (Pattern "baz") "foo bar" == ["foo bar"]
-- | -- empty string
-- | split (Pattern "") "foo bar" == ["f","o","o"," ","b","a","r"]
-- | ```
foreign import split :: Pattern -> String -> Array String

Expand Down

0 comments on commit d3884a1

Please sign in to comment.