File: regex.py

package info (click to toggle)
python-pypartpicker 1.9.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 124 kB
  • sloc: python: 393; makefile: 4
file content (16 lines) | stat: -rw-r--r-- 434 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import re

LIST_REGEX = re.compile(
    "((?:http|https)://(?:[a-z]{2}.)?pcpartpicker.com/(?:(?:list/(?:[a-zA-Z0-9]{6}))|(?:user/(?:[\\w]+)/saved/(?:[a-zA-Z0-9]{6}))))"
)
PRODUCT_REGEX = re.compile(
    "((?:http|https)://(?:[a-z]{2}.)?pcpartpicker.com/product/(?:[a-zA-Z0-9]{6}))"
)


def get_list_links(string):
    return re.findall(LIST_REGEX, string)


def get_product_links(string):
    return re.findall(PRODUCT_REGEX, string)