I have this htaccess code
RewriteRule ^/([uge])/([^/]+)$ /$1/$2/
But I could not understand what was doing [^/]+? I searched this on Google for a while, but I couldn’t get what I wanted.
[^/]+
Here you have two basic regex constructs
Character class
See character classes at regular-expressions.info
[...] is a character class, means that this construction corresponds to one character from the class (inside square brackets).
[...]
Your class begins with ^, which gives the character class a special meaning; its negative character class ( [^...]) means matching anything that is not part of the class.
^
[^...]
Quantifier
. regular-expressions.info
+ - , 1
+
, , : $ . , .
$
regular-expressions.info
([^/]+)$ , .
([^/]+)$
[^/] , /.
[^/]
/
:
1 , /
, [ ] ^ , , :
[
]
[^/] , /[^/]+ 1 , /
[^/] , /
[^/]+ 1 , /
[any_character] - charclass Ref. [^any_character] - charclass negated Ref.
[any_character]
[^any_character]
Anchors Ref:
^ : ^ (), .
charclass Ref: :
, (]), (), (^) (-). . [+ *]. , , .
Ref+ .
, /. , , /.
^/([uge])/([^/]+)$
/followed by u or g or ethen /follows and ends with one or more characters other than /
()(parentheses) are used for: parentheses Create a backlink Ref
()
An expression [^/]matches any character that is not /, and a quantifier +means that the expression to the left of the quantifier must appear once.