I have this htaccess code
RewriteRule ^/([uge])/([^/]+)$ /$1/$2/
But I couldn't really understand what does [^/]+ do?
I've been searching this on Google for awhile, but I couldn't get what I wanted.
You have two basic regex constructs here
Character class
See character classes on regular-expressions.info
[...] is a character class, means this construct matches one character from the class (from inside the square brackets).
Your class starts with a ^, that gives the character class a special meaning, its a negated character class ([^...]), means matches anything thats not part of the class.
Quantifier
See quantifiers on regular-expressions.info
+ is a quantifier, meaning 1 or more
Meaning of your regex
To understand what this is doing you have also to take the next thing into account, the $ at the end. This is an anchor that matches the end of the string.
See anchors on regular-expressions.info
so ([^/]+)$ matches all characters at the end of the string that are not slashes.
Here you can also find a basic tutorial
[^/] means any character not matching /.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With