Hi, Guest ~ Login or Register

Regular Expression Syntax

Regular Expression Syntax

Listed In Apache » Configuration — Viewing Full Tutorial
What are regular expressions?
Regular expressions are used in many languages, but this tutorial is aimed at .htaccess. You can find use of it in Perl, PHP and C/C++. Regular Expressions (Regex) are used for searching, matching, replacing and so on using wildcards.

Regex is used in .htaccess for things such as mod_rewrite.

General Syntax
^ - start of a string. You need to begin with this with Regex in .htaccess.
$ - end of a string. If you're used to PHP and so on, forget this.
(.*) - wildcard
Conditionals etc..
. - single charachter
(x|y|z) - This is similar to boolean in PHP, it means x or y or z.
(...) - Grouped section
[hijkl] - Item in the range of h, i, j, k or l
[^abcd] - Item not in the range of a, b, c or d. For example: e.
!( - pattern - ) - should not occur. replace - pattern - with the rule, e.g !((x|y|z)) means x y or z mustn't occur in the string
Counting occurences
x? - 0 or 1 of x / These two are pretty useless, but I'll include them anyway
a* - 0 or more of a. |
a+ - 1 or more of a.
x{3} - exactly 3 of x
x{4,} 4 or more of x
x{1,3} 1 to 3 of x




Working Beta

  1. The Forums
    These are mostly functional. If you see any weird bugs, post a thread about it and an administrator will do something.
  2. Tutorial Writing
    You can now submit tutorials to the brand new management system.
  3. Tutorials Home
    View tutorials by categories and search for them here.
  4. Shoutbox
    See below. Registered users only!

Register

Newest User

Say hi to Lirette25! Lirette25 joined on Monday, 14th July.

Sponsor

Check out Next day fake id

Shoutbox