Metadata-Version: 2.1
Name: bistring
Version: 0.5.0
Summary: Bidirectionally transformed strings
Home-page: https://github.com/microsoft/bistring
Author: Microsoft Research Montreal
Author-email: msrmtle@microsoft.com
License: MIT
Keywords: bistring string non-destructive
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Text Processing :: General
Classifier: Typing :: Typed
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
Provides-Extra: dev

bistring
========

|PyPI version|

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
    '𝕿𝖍𝖊 𝖖𝖚𝖎𝖈𝖐, 𝖇𝖗𝖔𝖜𝖓 🦊'

This allows you to perform very aggressive text processing completely invisibly.

.. |PyPI version| image:: https://badge.fury.io/py/bistring.svg
    :target: https://pypi.org/project/bistring/


