FenixRefO


NameFenixRefO JSON
Version 0.13.1 PyPI version JSON
download
home_pagehttps://github.com/javimansilla/refo
SummaryRegular expressions for objects
upload_time2024-06-21 20:44:29
maintainerNone
docs_urlNone
authorRafael Carrascosa
requires_python<4.0,>=3.8
licenseNone
keywords regular expressions regexp re objects classes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            REfO
====

Lacking a proper name, REfO stands for "Regular Expressions for Objects".

It's a python library that supplies a functionality very similar to the python
`re` module (regular expressions) but for arbitrary sequences of objects
instead of strings (sequences of characters).

In addition to that, it's possible to match each object in a sequence with
not only equality, but an arbitrary python function.
For example, if you have a sequence of integers you can make a regular
expression that asks for a even number followed by a prime number
followed by a 3-divisible number.

This software was written by Rafael Carrascosa while working at Machinalis in
the first months of 2012.

Contact: rcarrascosa@machinalis.com
or rafacarrascosa xyz gmail.com (replace " xyz " with "@")

[![Build Status](https://travis-ci.org/gjhiggins/refo.png?branch=master)](https://travis-ci.org/gjhiggins/refo)

How to use it
-------------

The syntax is a little bit different than python's re, and similar to that of
pyparsing, you have to more-or-less explicitly build the syntax tree of
your regular expression. For instance:

`"ab"` is `Literal("a") + Literal("b")`

`"a*"` is `Star(Literal("a"))`

`"(ab)+|(bb)*?"` is:

    a = Literal("a")
    b = Literal("b")
    regex = Plus(a + b) | Star(b + b, greedy=False)

You can also assign a group to any sub-match and later on retrieve the matched
content, for instance:

    regex = Group(Plus(a + b), "foobar")  | (b + b)
    m = match(regex, "abab")
    print m.span("foobar")  # prints (0, 4)

For more, check out the examples in the examples folder.


How we use it
-------------

At Machinalis we use REfO for applications similar to that in
`examples/words.py`, check it out!


About the implementation
------------------------

I use a Thompson-like virtual machine aproach, which ensures polynomial time
worst-case complexity. See `examples/poly_time.py` for an example of this.

The implementation is heavily based on Russ Cox notes, see
http://swtch.com/~rsc/regexp/regexp2.html for the source.

If you go to read the code, some glossary:

 - RE  --  regular expression
 - VM  --  virtual machine
 - Epsilon transitions  --  All VM instructions that do not consume a symbol
                            or stop the thread (for example an Accept).


Acknowledgements
----------------

Thanks Russ Cox for sharing the awesome info and insights on your web site.

Thanks Javier Mansilla for reviewing the code and being enthusiastic about it.

Thanks Machinalis for everything :)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/javimansilla/refo",
    "name": "FenixRefO",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "regular expressions, regexp, re, objects, classes",
    "author": "Rafael Carrascosa",
    "author_email": "rafacarrascosa@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/24/cc/6766ae549212657f160273d598e0d5640332f4c905b65bcae4afaa674279/fenixrefo-0.13.1.tar.gz",
    "platform": null,
    "description": "REfO\n====\n\nLacking a proper name, REfO stands for \"Regular Expressions for Objects\".\n\nIt's a python library that supplies a functionality very similar to the python\n`re` module (regular expressions) but for arbitrary sequences of objects\ninstead of strings (sequences of characters).\n\nIn addition to that, it's possible to match each object in a sequence with\nnot only equality, but an arbitrary python function.\nFor example, if you have a sequence of integers you can make a regular\nexpression that asks for a even number followed by a prime number\nfollowed by a 3-divisible number.\n\nThis software was written by Rafael Carrascosa while working at Machinalis in\nthe first months of 2012.\n\nContact: rcarrascosa@machinalis.com\nor rafacarrascosa xyz gmail.com (replace \" xyz \" with \"@\")\n\n[![Build Status](https://travis-ci.org/gjhiggins/refo.png?branch=master)](https://travis-ci.org/gjhiggins/refo)\n\nHow to use it\n-------------\n\nThe syntax is a little bit different than python's re, and similar to that of\npyparsing, you have to more-or-less explicitly build the syntax tree of\nyour regular expression. For instance:\n\n`\"ab\"` is `Literal(\"a\") + Literal(\"b\")`\n\n`\"a*\"` is `Star(Literal(\"a\"))`\n\n`\"(ab)+|(bb)*?\"` is:\n\n    a = Literal(\"a\")\n    b = Literal(\"b\")\n    regex = Plus(a + b) | Star(b + b, greedy=False)\n\nYou can also assign a group to any sub-match and later on retrieve the matched\ncontent, for instance:\n\n    regex = Group(Plus(a + b), \"foobar\")  | (b + b)\n    m = match(regex, \"abab\")\n    print m.span(\"foobar\")  # prints (0, 4)\n\nFor more, check out the examples in the examples folder.\n\n\nHow we use it\n-------------\n\nAt Machinalis we use REfO for applications similar to that in\n`examples/words.py`, check it out!\n\n\nAbout the implementation\n------------------------\n\nI use a Thompson-like virtual machine aproach, which ensures polynomial time\nworst-case complexity. See `examples/poly_time.py` for an example of this.\n\nThe implementation is heavily based on Russ Cox notes, see\nhttp://swtch.com/~rsc/regexp/regexp2.html for the source.\n\nIf you go to read the code, some glossary:\n\n - RE  --  regular expression\n - VM  --  virtual machine\n - Epsilon transitions  --  All VM instructions that do not consume a symbol\n                            or stop the thread (for example an Accept).\n\n\nAcknowledgements\n----------------\n\nThanks Russ Cox for sharing the awesome info and insights on your web site.\n\nThanks Javier Mansilla for reviewing the code and being enthusiastic about it.\n\nThanks Machinalis for everything :)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Regular expressions for objects",
    "version": "0.13.1",
    "project_urls": {
        "Homepage": "https://github.com/javimansilla/refo",
        "Repository": "https://github.com/javimansilla/refo"
    },
    "split_keywords": [
        "regular expressions",
        " regexp",
        " re",
        " objects",
        " classes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fff3657c7a62ad5bcd75268c112303586f501a2d5503a46302a19fcf314392ac",
                "md5": "f7818336799007d1f27f1a44b49a7305",
                "sha256": "cbacd8d67eaf9df005b3a0c152aaf54eba16a4d86e57e179acb6a791ad83ba6a"
            },
            "downloads": -1,
            "filename": "fenixrefo-0.13.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f7818336799007d1f27f1a44b49a7305",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 9803,
            "upload_time": "2024-06-21T20:44:27",
            "upload_time_iso_8601": "2024-06-21T20:44:27.013464Z",
            "url": "https://files.pythonhosted.org/packages/ff/f3/657c7a62ad5bcd75268c112303586f501a2d5503a46302a19fcf314392ac/fenixrefo-0.13.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "24cc6766ae549212657f160273d598e0d5640332f4c905b65bcae4afaa674279",
                "md5": "cbadafa99bb3286a50e54e41fe450980",
                "sha256": "6e9de2efcd5525b3600d71ce1bbe979f9877f527973a2e585cb63d75b40d16aa"
            },
            "downloads": -1,
            "filename": "fenixrefo-0.13.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cbadafa99bb3286a50e54e41fe450980",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 8869,
            "upload_time": "2024-06-21T20:44:29",
            "upload_time_iso_8601": "2024-06-21T20:44:29.199200Z",
            "url": "https://files.pythonhosted.org/packages/24/cc/6766ae549212657f160273d598e0d5640332f4c905b65bcae4afaa674279/fenixrefo-0.13.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-21 20:44:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "javimansilla",
    "github_project": "refo",
    "github_not_found": true,
    "lcname": "fenixrefo"
}
        
Elapsed time: 0.50448s