I am trying to come up with a regular expression to match a particular pattern.
If a sample test string is as follows:
/wp-content/themes/sometheme/style.css
The regular expression should:
- MATCH
/wp-content/themes/exactly, from the beginning, and should also match/style.cssexactly, from the end. - NOT MATCH, when the remainder (between the beginning and end strings in item 1) is
rwsarbor - MATCH, when the remainder is anything BUT
mythemename - For the dynamic part in the middle, it should match any number of characters, and any character type (not just a-z, 0-9, etc)
For example, it should not match:
/wp-content/themes/mythemename/style.css
It should match
/wp-content/themes/jfdskjh-ekhb234_sf/style.css
/wp-content/themes/another_theme/style.css
/wp-content/themes/any_other-theme/style.css
/wp-content/themes/!@#$%^&*()_+{}|:"?</style.css
This one is a little out of my league in terms of complexity, so I am looking to the community for assistance.
Try this :
Demo : http://regexr.com?30ote
Hint : Using Negative look-ahead assertion.