I am trying to validate following type of string using regular expressions in PHP. Using PHP 5.5.9.
String is in following format:
/[sometext]/course/[sometext1]/[sometext2]
What I need is a regex that will accept string that is only in that format and nothing else. Meaning these would be invalid:
/aaa/course/bbb/ccc/
/aaa/course/bbb/ccc/ddd
What I have so far is this:
/\/(?P<domain>.+?)\/course\/(?P<courseid>.+?)\/(?P<reportname>.+?)/
Any ideas?
Update:
With the help from all posters and especially wiktor-stribi%c5%bcew I got this one that works:
$regex = '#^/(?P<domain>[^/]+)/course/(?P<courseid>[^/]+)/(?P<reportname>[^/]+)$#';