STRling 2.4.4__tar.gz → 2.5.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: STRling
3
- Version: 2.4.4
3
+ Version: 2.5.0
4
4
  Description-Content-Type: text/markdown
5
5
 
6
6
  # STRling
@@ -128,3 +128,67 @@ def not_behind(pattern):
128
128
  raise STRlingError(message)
129
129
 
130
130
  return Pattern(f'(?<!{pattern})', composite=True)
131
+
132
+ def has(pattern):
133
+ """
134
+ A lookaround that checks for the presence of the specified pattern anywhere in the string without including it in the result.
135
+
136
+ Parameters:
137
+ - pattern (Pattern/str): The pattern to look for.
138
+
139
+ Returns:
140
+ - An instance of the Pattern class.
141
+
142
+ Examples:
143
+ ```
144
+ # Only matches if the string contains the pattern.
145
+ my_pattern = s.has(pattern)
146
+ ```
147
+ """
148
+
149
+ if isinstance(pattern, str):
150
+ pattern = lit(pattern)
151
+
152
+ if not isinstance(pattern, Pattern):
153
+ message = """
154
+ Method: simply.has(pattern)
155
+
156
+ The parameter must be an instance of `Pattern` or `str`.
157
+
158
+ Use a string such as "123abc$" to match literal characters, or use a predefined set like `simply.letter()`.
159
+ """
160
+ raise STRlingError(message)
161
+
162
+ return Pattern(f'(?=.*{pattern})', composite=True)
163
+
164
+ def has_not(pattern):
165
+ """
166
+ A lookaround that checks for the absence of the specified pattern everywhere in the string without including it in the result.
167
+
168
+ Parameters:
169
+ - pattern (Pattern/str): The pattern to look for and ensure is absent.
170
+
171
+ Returns:
172
+ - An instance of the Pattern class.
173
+
174
+ Examples:
175
+ ```
176
+ # Only matches if the string doesn't contain the pattern.
177
+ my_pattern = s.has_not(pattern)
178
+ ```
179
+ """
180
+
181
+ if isinstance(pattern, str):
182
+ pattern = lit(pattern)
183
+
184
+ if not isinstance(pattern, Pattern):
185
+ message = """
186
+ Method: simply.has(pattern)
187
+
188
+ The parameter must be an instance of `Pattern` or `str`.
189
+
190
+ Use a string such as "123abc$" to match literal characters, or use a predefined set like `simply.letter()`.
191
+ """
192
+ raise STRlingError(message)
193
+
194
+ return Pattern(f'(?!.*{pattern})', composite=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: STRling
3
- Version: 2.4.4
3
+ Version: 2.5.0
4
4
  Description-Content-Type: text/markdown
5
5
 
6
6
  # STRling
@@ -9,7 +9,7 @@ with open('./docs/pypi_docs.md', 'r') as f:
9
9
 
10
10
  setup(
11
11
  name='STRling',
12
- version='2.4.4',
12
+ version='2.5.0',
13
13
  packages=find_packages(),
14
14
  install_requires=[
15
15
  # Add dependencies here.
File without changes
File without changes
File without changes
File without changes