Reputation: 6116
Regexp: editClassification/(?P<pk>[\d+])
String to match: foo/editClassification/10
Upvotes: 0
Views: 536
Reputation: 5596
Your \d+
was inside a character class (More info can be found at Regexp Tutorial or the PHP Docs). This means any letter inside is selected. For example, (a|b|c)
is equivalent to the character class [abc]
. So your character class was matching either one digit, or a +
.
You should remove the [
square brackets]
around the \d+
. Your new RegEx:
editClassification/(?P<pk>\d+)
Alternatively, you could just move the +
outside the character class, but that just wastes space.
Upvotes: 1
Reputation: 133899
Because \d+
is within a character class ([...]
); [\d+]
matches exactly one character that is either a digit or +
.
You were supposed to write (?P<pk>\d+)
instead.
Upvotes: 2