Registry / serialization / stringparser

stringparser

JSON →
library0.7pypypi✓ verified 83d ago

stringparser is a Python library that provides an easy-to-use interface for pattern matching and information extraction from strings, built on top of the 'parsy' library. It simplifies the process of defining structured patterns to parse text into Python dictionaries. The current version is 0.7, and releases are generally made on an as-needed basis rather than a fixed cadence.

pip install stringparser
INSTALL
IMPORT
SIG · STRINGPARSER
S
stringparser
serializationpythonv0.7
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Parser
from stringparser import Parser
from stringparser import StringParser

This quickstart demonstrates how to create a `StringParser` instance with a pattern string and use it to extract data from input strings. The pattern uses `{key:type}` syntax for named capture groups and type conversion.

from stringparser import StringParser # Define a parser using a pattern string parser = StringParser("Hello {name:s}! Your age is {age:d}.") # Parse a matching string result = parser.parse("Hello Alice! Your age is 30.") print(result) # Expected output: {'name': 'Alice', 'age': 30} # Example with a different pattern and input date_parser = StringParser("{day:d}/{month:d}/{year:d}") date_result = date_parser.parse("25/12/2023") print(date_result) # Expected output: {'day': 25, 'month': 12, 'year': 2023}
Debug
Known issues
gotchastringparser patterns are NOT regular expressions. While they define matching rules, they use a distinct syntax based on 'parsy' for structured parsing, not regex.
fix
Refer to the stringparser documentation for its specific pattern syntax, which uses '{name:type}' for capturing and type conversion.
affects: All versions (0.1+)
gotchaAs a 0.x version library, stringparser's API stability is not strictly guaranteed. Minor versions (e.g., 0.7 to 0.8) may introduce backward-incompatible changes.
fix
Pin your dependency to a specific minor version (e.g., `stringparser==0.7`) and review the project's changelog or GitHub releases for any breaking changes before upgrading.
affects: All 0.x versions
gotchaInput strings must match the defined pattern exactly. If a portion of the input does not conform to the pattern, a `ParsingError` will be raised, unlike regex which might partially match or return None.
fix
Ensure your input data strictly adheres to the defined pattern. For more flexible parsing, you might need to combine multiple patterns or handle `ParsingError` explicitly.
affects: All versions (0.1+)
Upgrade
Version history
0.7latest on PyPI · released Nov 16, 2023
Audit
Dependencies
parsyrequiredCore parsing engine used internally by stringparser.
Agent activity
5 hits · last 30 days
node
4
Resources
stringparser — pip install stringparser · libregistry