string-between


Namestring-between JSON
Version 0.0.7 PyPI version JSON
download
home_pagehttps://github.com/sfinktah/string_between
SummaryTBA
upload_time2022-12-04 21:11:14
maintainer
docs_urlNone
authorChristopher Anderson
requires_python>=2.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            string_between

Using string_between
====================

.. code-block:: python

    from string_between import string_between
    
    # syntax
    string_between(left, right, subject, [,start [,end]] [,greedy=False] [,inclusive=False] [,repl=None] [,retn_all_on_fail=False] [,retn_class=False] [,rightmost=False]) -> str

    Return the substring delineated by `left` and `right` within the search
    space subject[start:end].  Optional default_arguments `start` and `end` 
    are interpreted as per slice notation.
    
    Return the string between `left` and `right` or empty string on failure

    @param left str|re|list: left anchor, or '' for start of subject; regex must be compiled
    @param right str|re|list: right anchor, or '' for end of subject; regex must be compiled
    @param subject: string to be searched
    @param start: start index for search
    @param end: start and end are interpreted as in slice notation.
    @param greedy: match biggest substring possible
    @param inclusive: include anchors in result
    @param repl [str|callable]: replace matched substring with repl in result
    @param retn_all_on_fail: return original string if match not made
    @param retn_class: return result as StringBetweenResult object
    @param rightmost: match rightmost substring, possible by greedily searching for `left`; implies `greedy`
    @return matched substring | original string | empty | StringBetweenResult object
    
    Note: regular expressions must be compiled

    If left and right are lists, then string_between() takes a value from
    each list and uses them as left and right on subject. If right has
    fewer values than left, then an empty string is used for the rest of
    replacement values. The converse applies. If left is a list and right 
    is a string, then this replacement string is used for every value of left. 
    The converse also applies.

    Examples:
    ---------

    >>> s = 'The *quick* brown [fox] jumps _over_ the **lazy** [dog]'
    >>> string_between('[', ']', s)
    'fox'

    >>> string_between('[', ']', s, inclusive=True)
    '[fox]'

    >>> string_between('[', ']', s, rightmost=True)
    'dog'

    >>> string_between('[', ']', s, inclusive=True, greedy=True)
    '[fox] jumps _over_ the **lazy** [dog]'
    
    > b'result'

Changelog
=========

0.0.1: initial release (2021-09-07)

0.0.6: many things since then (2020-09-16)




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sfinktah/string_between",
    "name": "string-between",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Christopher Anderson",
    "author_email": "sfinktah@github.spamtrak.org",
    "download_url": "https://files.pythonhosted.org/packages/78/48/c4d0cf31bd314830b1fbfb4ed20edde8f62796af7662d11a142b1dd7c31b/string_between-0.0.7.tar.gz",
    "platform": null,
    "description": "string_between\n\nUsing string_between\n====================\n\n.. code-block:: python\n\n    from string_between import string_between\n    \n    # syntax\n    string_between(left, right, subject, [,start [,end]] [,greedy=False] [,inclusive=False] [,repl=None] [,retn_all_on_fail=False] [,retn_class=False] [,rightmost=False]) -> str\n\n    Return the substring delineated by `left` and `right` within the search\n    space subject[start:end].  Optional default_arguments `start` and `end` \n    are interpreted as per slice notation.\n    \n    Return the string between `left` and `right` or empty string on failure\n\n    @param left str|re|list: left anchor, or '' for start of subject; regex must be compiled\n    @param right str|re|list: right anchor, or '' for end of subject; regex must be compiled\n    @param subject: string to be searched\n    @param start: start index for search\n    @param end: start and end are interpreted as in slice notation.\n    @param greedy: match biggest substring possible\n    @param inclusive: include anchors in result\n    @param repl [str|callable]: replace matched substring with repl in result\n    @param retn_all_on_fail: return original string if match not made\n    @param retn_class: return result as StringBetweenResult object\n    @param rightmost: match rightmost substring, possible by greedily searching for `left`; implies `greedy`\n    @return matched substring | original string | empty | StringBetweenResult object\n    \n    Note: regular expressions must be compiled\n\n    If left and right are lists, then string_between() takes a value from\n    each list and uses them as left and right on subject. If right has\n    fewer values than left, then an empty string is used for the rest of\n    replacement values. The converse applies. If left is a list and right \n    is a string, then this replacement string is used for every value of left. \n    The converse also applies.\n\n    Examples:\n    ---------\n\n    >>> s = 'The *quick* brown [fox] jumps _over_ the **lazy** [dog]'\n    >>> string_between('[', ']', s)\n    'fox'\n\n    >>> string_between('[', ']', s, inclusive=True)\n    '[fox]'\n\n    >>> string_between('[', ']', s, rightmost=True)\n    'dog'\n\n    >>> string_between('[', ']', s, inclusive=True, greedy=True)\n    '[fox] jumps _over_ the **lazy** [dog]'\n    \n    > b'result'\n\nChangelog\n=========\n\n0.0.1: initial release (2021-09-07)\n\n0.0.6: many things since then (2020-09-16)\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "TBA",
    "version": "0.0.7",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "144f55e11e75ec9dbabb5b30600b001d",
                "sha256": "2c805aab7e6582ca6043719a9e3f0c2cdb804fd16c495d38ee151ce0da745861"
            },
            "downloads": -1,
            "filename": "string_between-0.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "144f55e11e75ec9dbabb5b30600b001d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 6516,
            "upload_time": "2022-12-04T21:11:14",
            "upload_time_iso_8601": "2022-12-04T21:11:14.580318Z",
            "url": "https://files.pythonhosted.org/packages/78/48/c4d0cf31bd314830b1fbfb4ed20edde8f62796af7662d11a142b1dd7c31b/string_between-0.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-04 21:11:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "sfinktah",
    "github_project": "string_between",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "string-between"
}
        
Elapsed time: 0.02606s