STRling 0.0.2__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- strling-1.0.0/PKG-INFO +194 -0
- strling-1.0.0/README.md +189 -0
- strling-1.0.0/STRling/__init__.py +2 -0
- strling-1.0.0/STRling/lib.py +517 -0
- strling-1.0.0/STRling.egg-info/PKG-INFO +194 -0
- {strling-0.0.2 → strling-1.0.0}/setup.py +1 -1
- strling-0.0.2/PKG-INFO +0 -75
- strling-0.0.2/README.md +0 -70
- strling-0.0.2/STRling/__init__.py +0 -1
- strling-0.0.2/STRling/lib.py +0 -136
- strling-0.0.2/STRling.egg-info/PKG-INFO +0 -75
- {strling-0.0.2 → strling-1.0.0}/STRling.egg-info/SOURCES.txt +0 -0
- {strling-0.0.2 → strling-1.0.0}/STRling.egg-info/dependency_links.txt +0 -0
- {strling-0.0.2 → strling-1.0.0}/STRling.egg-info/top_level.txt +0 -0
- {strling-0.0.2 → strling-1.0.0}/setup.cfg +0 -0
strling-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: STRling
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Description-Content-Type: text/markdown
|
|
5
|
+
|
|
6
|
+
# STRling
|
|
7
|
+
|
|
8
|
+
## The Next Generation of Regular Expressions
|
|
9
|
+
|
|
10
|
+
STRling is a powerful next-generation syntax designed as a user interface for writing regular expressions (RegEx) with an object-oriented approach. STRling is a simpler syntax than RegEx while maintaining the same underlying power and flexibility, making string validation more intuitive and less error-prone. Best of all, STRling syntax substitutes valid RegEx patterns, making it fully compatible with all traditional RegEx libraries and methods.
|
|
11
|
+
|
|
12
|
+
### Why STRling?
|
|
13
|
+
|
|
14
|
+
STRling recognizes the cryptic nature of RegEx can be challenging and susceptibility to errors. We provide a well-structured syntax that promotes readability and maintainability, empowering developers to focus on application logic rather than wrestling over difficult development tools. Most of all, we aim for a reliable product, which is why we only depend on built-in Python libraries.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### STRling's Mission
|
|
18
|
+
|
|
19
|
+
Our mission is to make RegEx a distant and outdated syntax by abstracting the complexities of RegEx into a clean, readable, and powerful interface. We strive to simplify string operations and ensure that developers can focus on building their applications without the steep learning curve of traditional RegEx. The previous alternative to RegEx was to learn the string validation syntax specific to each user input library, but STRling aims to unify the disparate syntaxes found across various libraries and frameworks into one simple library using only built-in Python packages.
|
|
20
|
+
|
|
21
|
+
### Key Features
|
|
22
|
+
|
|
23
|
+
- **High-Level Template Validation**: Quickly and easily validate common patterns using our template library.
|
|
24
|
+
- **Low-Level Pattern Construction**: Build complex RegEx patterns using a readable and maintainable, object-oriented syntax.
|
|
25
|
+
- **Escaping RegEx Jargon**: No longer write RegEx using complex jargon.
|
|
26
|
+
- **Dependencies**: Depends solely on built-in python libraries, fostering dependability and compatibility.
|
|
27
|
+
|
|
28
|
+
### Installation
|
|
29
|
+
|
|
30
|
+
Install STRling via pip:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
pip install STRling
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Documentation - Developmental Guide
|
|
37
|
+
|
|
38
|
+
Here's a quick example to demonstrate how easy it is to get started with STRling:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import re
|
|
42
|
+
from STRling import lit, group, merge
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
##########################################################
|
|
46
|
+
## Here are some real implementations of STRling syntax ##
|
|
47
|
+
##########################################################
|
|
48
|
+
|
|
49
|
+
# Most invoked functions have the range ability
|
|
50
|
+
# after their positional arguments as lib.letter()
|
|
51
|
+
|
|
52
|
+
any_letter = lib.letter() # [A-Za-z]
|
|
53
|
+
exactly_four_letters = lib.letter(4) # [A-Za-z]{4}
|
|
54
|
+
two_to_six_letters = lib.letter(2, 6) # [A-Za-z]{2, 6}
|
|
55
|
+
two_or_more_letters = lib.letter(2, '') # [A-Za-z]{2,}
|
|
56
|
+
|
|
57
|
+
# Using ahead (e.g., match 'foo' only if followed by 'bar')
|
|
58
|
+
foo_if_bar = lib.lit('foo') + lib.ahead('bar') # foo(?=bar)
|
|
59
|
+
|
|
60
|
+
# Using lookbehind (e.g., match 'bar' only if preceded by 'foo')
|
|
61
|
+
bar_if_foo = lib.behind('foo') + lib.lit('bar') # (?<=foo)bar
|
|
62
|
+
|
|
63
|
+
# Using or_ (e.g., match either 'cat' or 'dog')
|
|
64
|
+
cat_or_dog = lib.or_(lib.lit('cat'), lib.lit('dog')) # (?:cat|dog)
|
|
65
|
+
|
|
66
|
+
# Creating a named group (e.g., capturing a word)
|
|
67
|
+
letter_num = merge(lib.digit(), lib.letter()) # (?:\d[A-Za-z])
|
|
68
|
+
special1 = lib.group('word', lib.letter() + lib.may(letter_num()))
|
|
69
|
+
# special1 is equivalent to the RegEx (?P<word>[A-Za-z](?:\d[A-Za-z])?)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
first = group('first', lib.digit(3)) # (?P<first>\d{3})
|
|
73
|
+
second = group('second', lib.digit(3)) # (?P<second>\d{3})
|
|
74
|
+
third = group('third', lib.digit(4)) # (?P<third>\d{4})
|
|
75
|
+
h = lib.lit('-') # \-
|
|
76
|
+
|
|
77
|
+
phone_pattern = lib.group('phone', first + h + second + h + third)
|
|
78
|
+
# phone_pattern is equivalent to the RegEx pattern below
|
|
79
|
+
# (?P<phone>(?P<first>\d{3})\-(?P<second>\d{3})\-(?P<third>\d{4}))
|
|
80
|
+
|
|
81
|
+
# Sample string containing phone numbers
|
|
82
|
+
text = "Here are some phone numbers: 987-654-3210, 123-456-7890."
|
|
83
|
+
|
|
84
|
+
# Using the re package to search for the phone number pattern
|
|
85
|
+
matches = re.finditer(phone_pattern, text)
|
|
86
|
+
|
|
87
|
+
# Displaying the matches
|
|
88
|
+
for match in matches:
|
|
89
|
+
print('Match Index Range:', match.span())
|
|
90
|
+
print('"first" group:', match.group('first'))
|
|
91
|
+
print('"second" group:', match.group('second'))
|
|
92
|
+
print('"third" group:', match.group('third'))
|
|
93
|
+
print('"phone" group:', match.group('phone'))
|
|
94
|
+
|
|
95
|
+
# Match Index Range: (29, 41)
|
|
96
|
+
# "first" group: 987
|
|
97
|
+
# "second" group: 654
|
|
98
|
+
# "third" group: 3210
|
|
99
|
+
# "phone" group: 987-654-3210
|
|
100
|
+
|
|
101
|
+
# Match Index Range: (43, 55)
|
|
102
|
+
# "first" group: 123
|
|
103
|
+
# "second" group: 456
|
|
104
|
+
# "third" group: 7890
|
|
105
|
+
# "phone" group: 123-456-7890
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
##############################################################
|
|
109
|
+
## Here are all the lib methods with their equivalent RegEx ##
|
|
110
|
+
##############################################################
|
|
111
|
+
|
|
112
|
+
# Matches the literal provided string (no symbols or variables)
|
|
113
|
+
lib.lit('-*') # \-\*
|
|
114
|
+
|
|
115
|
+
# Matches any character between and including the two provided
|
|
116
|
+
lib.between('A', 'D') # [A-D]
|
|
117
|
+
|
|
118
|
+
# Matches any character in the provided string
|
|
119
|
+
lib.in_('abc') # [abc]
|
|
120
|
+
|
|
121
|
+
# Matches any character not in the provided string
|
|
122
|
+
lib.not_in('abc') # [^abc]
|
|
123
|
+
|
|
124
|
+
# Matches any digit
|
|
125
|
+
lib.digit() # \d
|
|
126
|
+
|
|
127
|
+
# Matches any letter
|
|
128
|
+
lib.letter() # [A-Za-z]
|
|
129
|
+
|
|
130
|
+
# Matches any uppercase letter
|
|
131
|
+
lib.upper() # [A-Z]
|
|
132
|
+
|
|
133
|
+
# Matches any lowercase letter
|
|
134
|
+
lib.lower() # [a-z]
|
|
135
|
+
|
|
136
|
+
# Matches any character besides newline
|
|
137
|
+
lib.any() # .
|
|
138
|
+
|
|
139
|
+
# Matches a newline character
|
|
140
|
+
lib.newline() # \n
|
|
141
|
+
|
|
142
|
+
# Matches a tab character
|
|
143
|
+
lib.tab() # \t
|
|
144
|
+
|
|
145
|
+
# Matches a carriage return
|
|
146
|
+
lib.carriage() # \r
|
|
147
|
+
|
|
148
|
+
# Matches a boundary character
|
|
149
|
+
lib.bound() # \b
|
|
150
|
+
|
|
151
|
+
# Matches the start of the string
|
|
152
|
+
# Doesn't accept range params
|
|
153
|
+
lib.start() # ^
|
|
154
|
+
|
|
155
|
+
# Matches the end of the string
|
|
156
|
+
# Doesn't accept range params
|
|
157
|
+
lib.end() # $
|
|
158
|
+
|
|
159
|
+
# Matches only where the provided pattern is found ahead
|
|
160
|
+
# Doesn't accept range params
|
|
161
|
+
lib.ahead() # (?=pattern)
|
|
162
|
+
|
|
163
|
+
# Matches only where the provided pattern is found behind
|
|
164
|
+
# Doesn't accept range params
|
|
165
|
+
lib.behind() # (?<=pattern)
|
|
166
|
+
|
|
167
|
+
# Matches only where the provided pattern is not found ahead
|
|
168
|
+
# Doesn't accept range params
|
|
169
|
+
lib.not_ahead() # (?!pattern)
|
|
170
|
+
|
|
171
|
+
# Matches only where the provided pattern is not found behind
|
|
172
|
+
# Doesn't accept range params
|
|
173
|
+
lib.not_behind() # (?<!pattern)
|
|
174
|
+
|
|
175
|
+
# Matches any of the provided patterns
|
|
176
|
+
lib.or_() # pattern1 | pattern2
|
|
177
|
+
|
|
178
|
+
# Matches 1 otherwise 0 of the provided pattern
|
|
179
|
+
lib.may() # pattern?
|
|
180
|
+
|
|
181
|
+
# Groups the provided patterns with a name
|
|
182
|
+
group() # (?P<name>pattern1 pattern2)
|
|
183
|
+
|
|
184
|
+
# Groups the provided patterns without a name
|
|
185
|
+
merge() # (?:pattern1 pattern2)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Simplify your string validation and matching tasks with STRling, the all-in-one solution for developers who need powerful yet user-friendly tools for working with strings. Download and start using STRling today!
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
To learn more about STRling, checkout [STRling on PyPI](https://pypi.org/project/STRling/) and [STRling on GitHub](https://github.com/TheCyberLocal/STRling)
|
|
193
|
+
|
|
194
|
+
To learn more about traditional RegEx syntax, checkout my GitHub repo at [RegEx.md](https://github.com/TheCyberLocal/styled-coding-notes/blob/main/regEx.md)
|
strling-1.0.0/README.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# STRling
|
|
2
|
+
|
|
3
|
+
## The Next Generation of Regular Expressions
|
|
4
|
+
|
|
5
|
+
STRling is a powerful next-generation syntax designed as a user interface for writing regular expressions (RegEx) with an object-oriented approach. STRling is a simpler syntax than RegEx while maintaining the same underlying power and flexibility, making string validation more intuitive and less error-prone. Best of all, STRling syntax substitutes valid RegEx patterns, making it fully compatible with all traditional RegEx libraries and methods.
|
|
6
|
+
|
|
7
|
+
### Why STRling?
|
|
8
|
+
|
|
9
|
+
STRling recognizes the cryptic nature of RegEx can be challenging and susceptibility to errors. We provide a well-structured syntax that promotes readability and maintainability, empowering developers to focus on application logic rather than wrestling over difficult development tools. Most of all, we aim for a reliable product, which is why we only depend on built-in Python libraries.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### STRling's Mission
|
|
13
|
+
|
|
14
|
+
Our mission is to make RegEx a distant and outdated syntax by abstracting the complexities of RegEx into a clean, readable, and powerful interface. We strive to simplify string operations and ensure that developers can focus on building their applications without the steep learning curve of traditional RegEx. The previous alternative to RegEx was to learn the string validation syntax specific to each user input library, but STRling aims to unify the disparate syntaxes found across various libraries and frameworks into one simple library using only built-in Python packages.
|
|
15
|
+
|
|
16
|
+
### Key Features
|
|
17
|
+
|
|
18
|
+
- **High-Level Template Validation**: Quickly and easily validate common patterns using our template library.
|
|
19
|
+
- **Low-Level Pattern Construction**: Build complex RegEx patterns using a readable and maintainable, object-oriented syntax.
|
|
20
|
+
- **Escaping RegEx Jargon**: No longer write RegEx using complex jargon.
|
|
21
|
+
- **Dependencies**: Depends solely on built-in python libraries, fostering dependability and compatibility.
|
|
22
|
+
|
|
23
|
+
### Installation
|
|
24
|
+
|
|
25
|
+
Install STRling via pip:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
pip install STRling
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Documentation - Developmental Guide
|
|
32
|
+
|
|
33
|
+
Here's a quick example to demonstrate how easy it is to get started with STRling:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
import re
|
|
37
|
+
from STRling import lit, group, merge
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
##########################################################
|
|
41
|
+
## Here are some real implementations of STRling syntax ##
|
|
42
|
+
##########################################################
|
|
43
|
+
|
|
44
|
+
# Most invoked functions have the range ability
|
|
45
|
+
# after their positional arguments as lib.letter()
|
|
46
|
+
|
|
47
|
+
any_letter = lib.letter() # [A-Za-z]
|
|
48
|
+
exactly_four_letters = lib.letter(4) # [A-Za-z]{4}
|
|
49
|
+
two_to_six_letters = lib.letter(2, 6) # [A-Za-z]{2, 6}
|
|
50
|
+
two_or_more_letters = lib.letter(2, '') # [A-Za-z]{2,}
|
|
51
|
+
|
|
52
|
+
# Using ahead (e.g., match 'foo' only if followed by 'bar')
|
|
53
|
+
foo_if_bar = lib.lit('foo') + lib.ahead('bar') # foo(?=bar)
|
|
54
|
+
|
|
55
|
+
# Using lookbehind (e.g., match 'bar' only if preceded by 'foo')
|
|
56
|
+
bar_if_foo = lib.behind('foo') + lib.lit('bar') # (?<=foo)bar
|
|
57
|
+
|
|
58
|
+
# Using or_ (e.g., match either 'cat' or 'dog')
|
|
59
|
+
cat_or_dog = lib.or_(lib.lit('cat'), lib.lit('dog')) # (?:cat|dog)
|
|
60
|
+
|
|
61
|
+
# Creating a named group (e.g., capturing a word)
|
|
62
|
+
letter_num = merge(lib.digit(), lib.letter()) # (?:\d[A-Za-z])
|
|
63
|
+
special1 = lib.group('word', lib.letter() + lib.may(letter_num()))
|
|
64
|
+
# special1 is equivalent to the RegEx (?P<word>[A-Za-z](?:\d[A-Za-z])?)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
first = group('first', lib.digit(3)) # (?P<first>\d{3})
|
|
68
|
+
second = group('second', lib.digit(3)) # (?P<second>\d{3})
|
|
69
|
+
third = group('third', lib.digit(4)) # (?P<third>\d{4})
|
|
70
|
+
h = lib.lit('-') # \-
|
|
71
|
+
|
|
72
|
+
phone_pattern = lib.group('phone', first + h + second + h + third)
|
|
73
|
+
# phone_pattern is equivalent to the RegEx pattern below
|
|
74
|
+
# (?P<phone>(?P<first>\d{3})\-(?P<second>\d{3})\-(?P<third>\d{4}))
|
|
75
|
+
|
|
76
|
+
# Sample string containing phone numbers
|
|
77
|
+
text = "Here are some phone numbers: 987-654-3210, 123-456-7890."
|
|
78
|
+
|
|
79
|
+
# Using the re package to search for the phone number pattern
|
|
80
|
+
matches = re.finditer(phone_pattern, text)
|
|
81
|
+
|
|
82
|
+
# Displaying the matches
|
|
83
|
+
for match in matches:
|
|
84
|
+
print('Match Index Range:', match.span())
|
|
85
|
+
print('"first" group:', match.group('first'))
|
|
86
|
+
print('"second" group:', match.group('second'))
|
|
87
|
+
print('"third" group:', match.group('third'))
|
|
88
|
+
print('"phone" group:', match.group('phone'))
|
|
89
|
+
|
|
90
|
+
# Match Index Range: (29, 41)
|
|
91
|
+
# "first" group: 987
|
|
92
|
+
# "second" group: 654
|
|
93
|
+
# "third" group: 3210
|
|
94
|
+
# "phone" group: 987-654-3210
|
|
95
|
+
|
|
96
|
+
# Match Index Range: (43, 55)
|
|
97
|
+
# "first" group: 123
|
|
98
|
+
# "second" group: 456
|
|
99
|
+
# "third" group: 7890
|
|
100
|
+
# "phone" group: 123-456-7890
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
##############################################################
|
|
104
|
+
## Here are all the lib methods with their equivalent RegEx ##
|
|
105
|
+
##############################################################
|
|
106
|
+
|
|
107
|
+
# Matches the literal provided string (no symbols or variables)
|
|
108
|
+
lib.lit('-*') # \-\*
|
|
109
|
+
|
|
110
|
+
# Matches any character between and including the two provided
|
|
111
|
+
lib.between('A', 'D') # [A-D]
|
|
112
|
+
|
|
113
|
+
# Matches any character in the provided string
|
|
114
|
+
lib.in_('abc') # [abc]
|
|
115
|
+
|
|
116
|
+
# Matches any character not in the provided string
|
|
117
|
+
lib.not_in('abc') # [^abc]
|
|
118
|
+
|
|
119
|
+
# Matches any digit
|
|
120
|
+
lib.digit() # \d
|
|
121
|
+
|
|
122
|
+
# Matches any letter
|
|
123
|
+
lib.letter() # [A-Za-z]
|
|
124
|
+
|
|
125
|
+
# Matches any uppercase letter
|
|
126
|
+
lib.upper() # [A-Z]
|
|
127
|
+
|
|
128
|
+
# Matches any lowercase letter
|
|
129
|
+
lib.lower() # [a-z]
|
|
130
|
+
|
|
131
|
+
# Matches any character besides newline
|
|
132
|
+
lib.any() # .
|
|
133
|
+
|
|
134
|
+
# Matches a newline character
|
|
135
|
+
lib.newline() # \n
|
|
136
|
+
|
|
137
|
+
# Matches a tab character
|
|
138
|
+
lib.tab() # \t
|
|
139
|
+
|
|
140
|
+
# Matches a carriage return
|
|
141
|
+
lib.carriage() # \r
|
|
142
|
+
|
|
143
|
+
# Matches a boundary character
|
|
144
|
+
lib.bound() # \b
|
|
145
|
+
|
|
146
|
+
# Matches the start of the string
|
|
147
|
+
# Doesn't accept range params
|
|
148
|
+
lib.start() # ^
|
|
149
|
+
|
|
150
|
+
# Matches the end of the string
|
|
151
|
+
# Doesn't accept range params
|
|
152
|
+
lib.end() # $
|
|
153
|
+
|
|
154
|
+
# Matches only where the provided pattern is found ahead
|
|
155
|
+
# Doesn't accept range params
|
|
156
|
+
lib.ahead() # (?=pattern)
|
|
157
|
+
|
|
158
|
+
# Matches only where the provided pattern is found behind
|
|
159
|
+
# Doesn't accept range params
|
|
160
|
+
lib.behind() # (?<=pattern)
|
|
161
|
+
|
|
162
|
+
# Matches only where the provided pattern is not found ahead
|
|
163
|
+
# Doesn't accept range params
|
|
164
|
+
lib.not_ahead() # (?!pattern)
|
|
165
|
+
|
|
166
|
+
# Matches only where the provided pattern is not found behind
|
|
167
|
+
# Doesn't accept range params
|
|
168
|
+
lib.not_behind() # (?<!pattern)
|
|
169
|
+
|
|
170
|
+
# Matches any of the provided patterns
|
|
171
|
+
lib.or_() # pattern1 | pattern2
|
|
172
|
+
|
|
173
|
+
# Matches 1 otherwise 0 of the provided pattern
|
|
174
|
+
lib.may() # pattern?
|
|
175
|
+
|
|
176
|
+
# Groups the provided patterns with a name
|
|
177
|
+
group() # (?P<name>pattern1 pattern2)
|
|
178
|
+
|
|
179
|
+
# Groups the provided patterns without a name
|
|
180
|
+
merge() # (?:pattern1 pattern2)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Simplify your string validation and matching tasks with STRling, the all-in-one solution for developers who need powerful yet user-friendly tools for working with strings. Download and start using STRling today!
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
To learn more about STRling, checkout [STRling on PyPI](https://pypi.org/project/STRling/) and [STRling on GitHub](https://github.com/TheCyberLocal/STRling)
|
|
188
|
+
|
|
189
|
+
To learn more about traditional RegEx syntax, checkout my GitHub repo at [RegEx.md](https://github.com/TheCyberLocal/styled-coding-notes/blob/main/regEx.md)
|