DEV Community

Kozo Oeda
Kozo Oeda

Posted on


Implementing auto-completion by Regex

Using an input as a pattern(this is a reversed way of major use cases), you can implement a simple word auto-completion feature easily!

import re

example_words = ["Python", "Linux", "HHKB", "Pizza", "Ninja"]

pattern = input()

for word in example_words:
    if re.match(pattern, word, re.IGNORECASE):

Input example




Version: Python 3

Top comments (0)

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.