Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/psbanka/regex_question
A test for creating a Python regex library
https://github.com/psbanka/regex_question
Last synced: 8 days ago
JSON representation
A test for creating a Python regex library
- Host: GitHub
- URL: https://github.com/psbanka/regex_question
- Owner: psbanka
- License: gpl-2.0
- Created: 2014-04-30T23:29:24.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-05-01T15:14:32.000Z (over 10 years ago)
- Last Synced: 2024-10-12T02:54:40.853Z (about 1 month ago)
- Size: 133 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Regex Question
A test for creating a Python regex library
## Overview
Create a deterministic regex engine with a subset of the full Regex features.
- The name of the class should be Regex.
- The constructor for the class should simply take a pattern string. For example:
```
regex = Regex('hello.world')
```will initialize a new Regex object with the regex pattern 'hello.world'
- The regex object will have a single function: search(matchString). The argument to the function is
the string that you want to search with the pattern provided in the constructor. The function will return
a list of matches, as the following example illustrates:```
regex("hello|world") = ["hello|world"]
regex("hello-world helloworld hello,world hello world") = ["hello-world", "hello,world", "hello world"]
```## Patterns that the Regex class must be able to use
- The complexity of the exercise lies primarily in the features that are implemented in the regex pattern string. At a minimum, the class must respect the following operators:
- the period ('.') operator: match any character. For example "hell." will match "hello" and "hellp"
- the question-mark ('?') operator: match zero or one instances of the previous character. For example, "hell?o" will match "hello" and "helo". Also, combining the dot and the question mark allows you to make the following expression: "hell?." will match "hello" and "help"
- the star ('*') operator: match one or more instances of the previous character. For example, "hel*o" will match "helllllo", "helo", etc.
## What we're looking for
- Code should have unit tests.
- Classes and complex methods should have docstrings
- Style:
- Functions should have meaningful names.
- Code should comply with PEP-8 standards, except a line-length of 120 characters may be used.