A simple Haskell module providing string manipulation functions inspired by Python's native str methods.
This library mimics common string methods from Python:
strip: remove leading and trailing whitespacecontains: check if a substring is presentreplaceFirst: replace the first occurrence of a substringreplaceAll: replace all occurrences of a substringsplit: split a string on a given delimiterjoin: join a list of strings with a given delimiter
Clone the repository and import the module in your Haskell project:
import StringUtilsstrip " hello world "
-- "hello world"contains "ell" "hello"
-- TruereplaceFirst "l" "L" "hello"
-- "heLlo"replaceAll "l" "L" "hello"
-- "heLLo"split "," "one,two,three"
-- ["one", "two", "three"]join ", " ["one", "two", "three"]
-- "one, two, three"| Haskell Function | Python Equivalent |
|---|---|
strip |
"str".strip() |
contains |
"substr" in str |
replaceFirst |
"str".replace(old, new, 1) |
replaceAll |
"str".replace(old, new) |
split |
"str".split(sep) |
join |
"sep".join(list) |
MIT