Regular Expressions 101

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^\/teacher\/(?<id>\d+)\/(?<method>(?:list)|(?:file)|(?:info))(?:(?<=list)$|(?:(?:(?<=file)|(?<=info))\/(?<name>.+$)))
/

Description

will match

^/teacher/<id>/list$ ^/teacher/<id>/file/<name>$ ^/teacher/<id>/info/<name>$

where

id = \d+ method = list | file | info name = .+

Submitted by anonymous - 3 years ago