Last active
December 22, 2015 20:43
-
-
Save chartjes/5acf166de83f1e8ef776 to your computer and use it in GitHub Desktop.
Regex challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have three strings | |
/kinto_read-only_1 | |
/kinto_read-only_1/db1 | |
/kinto_read-only_1/db1_1 | |
* I want matches only on the first string | |
* the digit after a _ could be any number (ie only_1, only_2, only_3) | |
* the number after db1 could be any number (ie db1, db2) | |
Need a pattern to match this using Python's PRE functions |
re.match("^/kinto_read-only_\d+$", "/kinto_read-only_1")
for completeness (with the ending $).
^ that one.
If you don't care about matching the exact kinto...
string, you could generalize Ikke's answer down to ^/[^/]+$
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So not something as simple as
^/(kinto_read-only_\d+)
?