Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/microsoft/bistring
Bidirectionally transformed strings
https://github.com/microsoft/bistring
sequence-alignment string
Last synced: about 1 month ago
JSON representation
Bidirectionally transformed strings
- Host: GitHub
- URL: https://github.com/microsoft/bistring
- Owner: microsoft
- License: mit
- Created: 2019-06-07T17:04:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-11T21:12:10.000Z (10 months ago)
- Last Synced: 2024-10-01T04:23:42.472Z (about 2 months ago)
- Topics: sequence-alignment, string
- Language: Python
- Size: 978 KB
- Stars: 366
- Watchers: 10
- Forks: 18
- Open Issues: 6
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-rainmana - microsoft/bistring - Bidirectionally transformed strings (Python)
README
bistring
========|Build status| |Documentation status|
The bistring library provides non-destructive versions of common string processing operations like normalization, case folding, and find/replace.
Each bistring remembers the original string, and how its substrings map to substrings of the modified version.For example:
.. code-block:: python
>>> from bistring import bistr
>>> s = bistr('πΏππ πππππ, πππππ π¦ πππππ ππππ πππ ππππ πΆ')
>>> s = s.normalize('NFKD') # Unicode normalization
>>> s = s.casefold() # Case-insensitivity
>>> s = s.replace('π¦', 'fox') # Replace emoji with text
>>> s = s.replace('πΆ', 'dog')
>>> s = s.sub(r'[^\w\s]+', '') # Strip everything but letters and spaces
>>> s = s[:19] # Extract a substring
>>> s.modified # The modified substring, after changes
'the quick brown fox'
>>> s.original # The original substring, before changes
'πΏππ πππππ, πππππ π¦'Languages
---------|PyPI version| |npm version|
bistring is available in multiple languages, currently `Python `_ and `JavaScript/TypeScript `_.
Ports to other languages are planned for the near future.The code is structured similarly in each language to make it easy to share algorithms, tests, and fixes between them.
The main differences come from trying to mirror the language's built-in string API.
If you want to contribute a bug fix or a new feature, feel free to implement it in any one of the supported languages, and we'll try to port it to the rest of them.Demo
----`Click here `_ for a live demo of the bistring library in your browser.
Contributing
------------This project welcomes contributions and suggestions.
Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution.
For details, visit https://cla.microsoft.com.When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment).
Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.This project has adopted the `Microsoft Open Source Code of Conduct `_.
For more information see the `Code of Conduct FAQ `_ or contact `[email protected] `_ with any additional questions or comments... |Build status| image:: https://github.com/microsoft/bistring/actions/workflows/ci.yml/badge.svg
:target: https://github.com/microsoft/bistring/actions/workflows/ci.yml
.. |Documentation status| image:: https://readthedocs.org/projects/bistring/badge/?version=latest
:target: https://bistring.readthedocs.io/en/latest/?badge=latest
.. |PyPI version| image:: https://badge.fury.io/py/bistring.svg
:target: https://pypi.org/project/bistring/
.. |npm version| image:: https://badge.fury.io/js/bistring.svg
:target: https://www.npmjs.com/package/bistring