Skip to content

roman91DE/stringUtils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

StringUtils

A simple Haskell module providing string manipulation functions inspired by Python's native str methods.

Features

This library mimics common string methods from Python:

  • strip: remove leading and trailing whitespace
  • contains: check if a substring is present
  • replaceFirst: replace the first occurrence of a substring
  • replaceAll: replace all occurrences of a substring
  • split: split a string on a given delimiter
  • join: join a list of strings with a given delimiter

Installation

Clone the repository and import the module in your Haskell project:

import StringUtils

Examples

strip

strip "   hello world  "
-- "hello world"

contains

contains "ell" "hello"
-- True

replaceFirst

replaceFirst "l" "L" "hello"
-- "heLlo"

replaceAll

replaceAll "l" "L" "hello"
-- "heLLo"

split

split "," "one,two,three"
-- ["one", "two", "three"]

join

join ", " ["one", "two", "three"]
-- "one, two, three"

Comparison with Python

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)

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published