Skip to main content

Find common prefix of strings, tuples, and nested structures

Project description

k3pattern

Action-CI Build Status Documentation Status Package

Find common prefix of several strings, tuples of string, or other nested structure, recursively by default.

k3pattern is a component of pykit3 project: a python3 toolkit set.

Find common prefix of several string, tuples of string, or other nested structure, recursively by default. It returns the shortest prefix: empty string or empty tuple is removed.

Install

pip install k3pattern

Synopsis

import k3pattern

k3pattern.common_prefix('abc', 'abd')                   # 'ab'
k3pattern.common_prefix((1, 2, 'abc'), (1, 2, 'abd'))   # (1, 2, 'ab')
k3pattern.common_prefix((1, 2, 'abc'), (1, 2, 'xyz'))   # (1, 2); empty prefix of 'abc' and 'xyz' is removed
k3pattern.common_prefix((1, 2, (5, 6)), (1, 2, (5, 7))) # (1, 2, (5,) )
k3pattern.common_prefix('abc', 'abd', 'abe')            # 'ab'; common prefix of more than two

Author

Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

k3pattern-0.1.3.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

k3pattern-0.1.3-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file k3pattern-0.1.3.tar.gz.

File metadata

  • Download URL: k3pattern-0.1.3.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for k3pattern-0.1.3.tar.gz
Algorithm Hash digest
SHA256 82f18a2a3cd18372c9572b49b8cbcdb03a40aaa1648d031ab154816844dccbc1
MD5 c663b1ef64f2829d330f716e6e00b710
BLAKE2b-256 4b68a2c4a32184022e4ee00a4906ffb714692bec219376b4316f272ae992af8a

See more details on using hashes here.

File details

Details for the file k3pattern-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: k3pattern-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for k3pattern-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 66242cde74d6da9830244200be2c20c5df91b0015fe3adea66143061389212be
MD5 e2fd6ae74e06b1eac0449f9a61aed8ec
BLAKE2b-256 d6ed4e11be168cdaf3cf9053e2cfe71dc09c0f8720dce471d0e796d06416b70b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page