Search code examples
regexstylish

Get URL-prefix like matching, using RegEx in Stylish?


I am coding custom CSS for Facebook using Stylish.
Everything goes well except that I need to have some custom values under the condition of URL-suffix. The only thing that comes close is URL-prefix which is the exact opposite.

So I was wondering if I could do something like:

Detect if URL is like either:
www.facebook.com/*/posts or just */post

where * could be any value. Is it possible to do this through RegEx? I googled it but I couldn't make anything out of it.

I want to apply some CSS code only when viewing some individual Facebook posts, and the URLbar shows:

www.facebook.com/User/Posts/PostID.php

Therefore, I would only like to detect if Post or post/postID.php exists and apply the style.


Solution

  • The below regex would match the links which contain the string /posts,

    (?=.*?\/posts).*
    

    DEMO