Skip to content

Commit

Permalink
Update usage of named captures with regular expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason A. Crome committed Jan 5, 2025
1 parent cd8dc6e commit b0e7da4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/Dancer2/Manual.pod
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,14 @@ expressions, providing more flexibility in matching URLs:
return "Category: $category_name";
};

It is also possible to use named captures in regular expressions:

# Matches URL: /product/12345
get qr{/product/(?<product_id>\d+)} => sub {
my $product_id = captures->{'product_id'};
return "Product ID: $product_id";
};

=head3 Combining Examples

# Matches URL: /item/42/specifications
Expand Down

0 comments on commit b0e7da4

Please sign in to comment.