Patterns
This page will help you add patterns in Linklever.
In Linklever, patterns are regular expressions (regexes), but you don't have to understand them to use Linklever. Instead, you can customize the examples here, or you can ask an AI like ChatGPT to create them for you.
Examples
You can customize these examples for your needs.
Pattern | Function | Explanation |
---|---|---|
^https://example\.com$ | Exact Match | Match a URL, e.g. https://example.com |
^https://subdomain\.example\.com$ | Exact Subdomain Match | Match a URL with a subdomain, e.g. https://subdomain.example.com |
^https://example\.com\/path$ | Exact Path Match | Match a URL with a path, e.g. https://example.com/path |
^(https?:\/\/)?(www\.)?example\.com(\/path)?$ | Optional protocol, www, and path | Match https://www.example.com/path but https , http , www , and /path are optional. |
Asking an AI
AI tools like ChatGPT are effective at generating URL pattern regexes.
Example Prompt:
Write a regex that matches all the common variations of a domain.
- https://example.com
- http://example.com
- www.example.com
- example.com
Response:
Here's a regex that matches the variations of the domain example.com as specified:
^(https?:\/\/)?(www\.)?example\.com$
Explanation:
^
- Asserts the start of the string.(https?:\/\/)?
- Matcheshttp://
orhttps://
, optionally (the?
makes it optional).(www\.)?
- Matcheswww.
optionally.example\.com
- Matches the domainexample.com
.$
- Asserts the end of the string.
Pattern quick facts
^
means "match a URL starting with", e.g.^example.com
matchesexample.com
but notwww.example.com
$
means "match a URL ending with", e.g.example.co$
matchesexample.co
but notexample.co.uk
- Use
\.
to match a dot, e.g.example\.com
matchesexample.com
- Use
\/
to match a forward-slash, e.g.example\.com\/path
matchesexample.com/path
- Use
.
to match any character e.g.example.com
matchesexample.com
andexampleZcom
. - Use
*
to match 0 or more, e.g.a*ok
matchesaok
andok
- Use
+
to match 1 or more, e.g.a+ok
matchesaok
but notok
- Use
?
to make something optional, e.g.(https)?
matcheshttps://
andhttp://
- Use
()
to make a group, e.g.(www\.)?example\.com
matcheswww.example.com
andexample.com
- Use
[]
to match multiple values, e.g.([\w\d]+)?\.?example\.com
matchessubdomain1.example.com
etcsubdomain2.example.com
- Use
\w
to match any letter, a to z or A to Z. - Use
\d
to match any number, 0 to 9.