Regular expression metacharacters

Metacharacters are the building blocks of regular expressions. Characters in RegEx are understood to be either a metacharacter with a special meaning or a regular character with a literal meaning.

The following are some common RegEx metacharacters and examples of what they would match or not match in RegEx.

Metacharacter Description Examples
\d Whole Number 0 – 9

\d\d\d = 327

\d\d = 81

\d = 4


\d\d\d ≠  24631

\d\d\d doesn’t return 24631 because 24631 contains 5 digits.  \d\d\d only matches for a 3-digit string.


\w Alphanumeric Character

\w\w\w = dog

\w\w\w\w = mule

\w\w = to


\w\w\w = 467

\w\w\w\w = 4673


\w\w\w ≠  boat

\w\w\w doesn’t return boat because boat contains 4 characters.


\w ≠  !

\w doesn’t return the exclamation point ! because it is a non-alphanumeric character.


\W Symbols

\W = %

\W = #

\W\W\W = @#%


\W\W\W\W ≠  dog8

\W\W\W\W doesn’t return dog8 because d, o, g, and 8 are alphanumeric characters.




Character set, at least one of which must be a match, but no more than one unless otherwise specified.

The order of the characters does not matter.

pand[ora] = panda

pand[ora] = pando


pand[ora] ≠  pandora

pand[ora] doesn’t bring back pandora because it is implied in pand[ora] that only 1 character in [ora] can return.


(Quantifiers that allow pand[ora] to match for pandora is discussed below.)




Character group, matches the characters abc or 123 in that exact order.

pand(ora) = pandora

pand(123) = pand123


pand(oar) ≠  pandora

pand(oar) does not match for pandora because it’s looking for the exact phrase pandoar.


| Alternation – allows for alternate matches. | operates like the Boolean OR. pand(abc|123) = pandora OR pand123
? Question mark matches when the character preceding ? occurs 0 or 1 time only, making the character match optional.

colou?r = colour (u is found 1 time)

colou?r = color (u is found 0 times)



Asterisk matches when the character preceding * matches 0 or more times.


Note: * in RegEx is different from * in dtSearch.  RegEx * is asking to find where the character (or grouping) preceding * is found ZERO or more times.  dtSearch * is asking to find where the string of characters preceding * or following * is found 1 or more times.

tre*= tree (e is found 2 times)

tre* = tre (e is found 1 time)

tre* = tr (e is found 0 times)


tre* ≠  trees

tre* doesn’t match the term trees because although “e” is found 2 times, it is followed by “s”, which is not accounted for in the RegEx.

+ Plus sign matches when the character preceding + matches 1 or more times. The + sign makes the character match mandatory.

tre+ = tree (e is found 2 times)

tre+ = tre (e is found 1 time)


tre+ ≠  tr (e is found 0 times)

tre+ doesn’t match for tr because e is found zero times in tr.


. (period) The period matches any alphanumeric character or symbol.

ton. = tone

ton. = ton#

ton. = ton4


ton. ≠  tones

ton. doesn’t match for the term tones because . by itself will only match for a single character, here, in the 4th position of the term.  In tones, s is the 5th character and is not accounted for in the RegEx.




Combine the metacharacters . and *, in that order .* to match for any character 0 or more times.


NOTE:  .* in RegEx is equivalent to dtSearch wildcard * operator.



tr.* = tr

tr.* = tre

tr.* = tree

tr.* = trees

tr.* = trough

tr.* = treadmill


RegEx quantifiers

RegEx use quantifiers to indicate the scope of a search string. You can use multiple quantifiers in your search string. The following table gives examples of the quantifiers you can use in your RegEx:

Quantifier Description Examples
{n} Matches when the preceding character, or character group, occurs n times exactly.

\d{3} = 836

\d{3} = 139

\d{3} = 532


pand[ora]{2} = pandar

pand[ora]{2} = pandoo

pand(ora){2} = pandoraora


pand[ora]{2} ≠  pandora

pand[ora]{2} doesn’t match for pandora because the quantifier {2} only allows for 2 letters from the character set [ora].


{n,m} Matches when the preceding character, or character group, occurs at least n times, and at most m times.

\d{2,5} = 97430

\d{2,5} = 9743

\d{2,5} = 97


\d{2,5} ≠  9

9 does not match because it is 1 digit, thus outside of the character range.


Escaping RegEx Metacharacters

When using RegEx to search for a character that is a reserved metacharacter, use the backslash \ to escape the character so it can be recognized. The following table gives an example on how to escape a reserved metacharacter when searching.

Search For RegEx Match Results

UK phone number






If the + sign is not escaped with a backslash, RegEx treats + as a quantifier instead of the literal plus sign character.



a basic git tutorial

DVCS (such as Git, Mercurial, Bazaar or Darcs)

Git was written by Linus Torvalds on the first version,He described the tool as “the stupid content tracker”,So don’t be afraid of Git.

It is a good idea to introduce yourself to Git with your name and
public email address before doing any operation. The easiest
way to do so is:

$ git config --global "Your Name Comes Here"
$ git config --global

Initialized empty Git repository in .git/

git init


git add .

Git tracks content not files

Many revision control systems provide an `add` command that tells the
system to start tracking changes to a new file. Git’s `add` command
does something simpler and more powerful: ‘git add’ is used both for new
and newly modified files, and in both cases it takes a snapshot of the
given files and stages that content in the index, ready for inclusion in
the next commit.

This snapshot is now stored in a temporary staging area which Git calls
the “index”. You can permanently store the contents of the index in the
repository with ‘git commit’:


git commit

A note on commit messages: Though not required, it’s a good idea to
begin the commit message with a single short (less than 50 character)
line summarizing the change, followed by a blank line and then a more
thorough description. The text up to the first blank line in a commit
message is treated as the commit title, and that title is used
throughout Git. For example, linkgit:git-format-patch[1] turns a
commit into email, and it uses the title on the Subject line and the
rest of the commit in the body.

 git commit -a

which will automatically notice any modified (but not new) files, add
them to the index, and commit, all in one step.

git add file1 file2 file3

You are now ready to commit. You can see what is about to be committed
using ‘git diff’ with the –cached option:

git diff --cached


$ git status


git log

If you also want to see complete diffs at each step, use

git log -p


git branch


git checkout 'your_branch'


git merge 'some one branch'

If the changes don’t conflict, you’re done. If there are conflicts,
markers will be left in the problematic files showing the conflict;

git diff

will show a nice graphical representation of the resulting history.


At this point you could delete the experimental branch with

git branch -d 'your_branch'


git clone /home/alice/project myrepo

The “pull” command thus performs two operations: it fetches changes
from a remote branch, then merges them into the current branch

local changes committed before
initiating this “pull”.

git pull /home/bob/myrepo master
git fetch /home/bob/myrepo master
git log -p HEAD..FETCH_HEAD
git difftool
git difftool --tool-help
git rm
git rm --cached
git commit --amend


git checkout -- <file>
git remote add pb
 git push [remote-name] [branch-name]
git remote show [remote-name]
git remote rename
git remote rm paul
git tag
git checkout -b version2 v2.0.0

permanently delete remote ref

git push --delete rep ref
git push rep :ref
eg..git push --delete origin dev  is equivalent to git push origin :dev
























































xdebug config



remove index.php from the URL when uses the CI framework(nginx)

  Apache is great(if you need help about Apache configuration you can see here),but Nginx ( pronounce “engine X”) maybe more powerful in high performance.So I write this paper for someone work with Nginx and php-fpm.

If it haven’t been installed,you can see here,

  • Open your configuration file in directory  /etc/nginx/conf.d/xxx.conf , add blow in your configuration file.
    location / { 
    try_files $uri $uri/ /index.php;

    Now we will explain what is the meaning,First “location /” is a directive location plus URI “/” that means if your URI just like this “” or “”.this role will take effect.Secondly,try_files directive will try to find the $url file.if not existence,then to find $url/.if both all not existence.”/index.php” file will be used as default file to run.So we can remove index.php from the URL.
    The configuration filelike this:

  • nginx_1

how to change window 10 title bar color

I update my window 7 to window 10 version 10240 feel better,but good day not very long.
I upgraded to win 10 version 10586,It suppose to give me a surprising,but it not,
only make me uncomfortable just like this:title bar looks not very clearly and briefly.


one day i found a method to change register table that can change the color whether or not change color of task bar.

step1:open your register table,win+r enter regedit

step2:find [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM]

step3:change “ColorPrevalence”=0

note:1 is colorful and 0 is white



if you want to change task bar color,just follow below steps

step1:find [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize]

step2:change ColorPrevalence”=0

note:0 is black and 1 is colorful

good luck to you!


php late static bindings lab



class A {
 public static function foo(){
 public static function who(){
 echo get_called_class()."\n";
class B extends A {
 public static function test(){
 public static function who(){
 echo get_called_class()."\n";

class C extends B {
 public static function who(){
 echo get_called_class()."\n";






php constructor lab

php 有几种编写构造函数的方法,第一种是__construct(),第二种是与类名同名的函数,不过据官方的文档说,到了5.3.3之后就不再支持了。As of PHP 5.3.3, methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn’t affect non-namespaced classes.


class a {
 public static function a(){
 echo "a";
echo "your php version: ".PHP_VERSION;


PHP Fatal error:  Constructor a::a() cannot be static



namespace Foo;
class a {
 public static function a(){
 echo "a";
echo "your php version: ".PHP_VERSION;


your php version: 5.5.20normal method


class a {
 public function a(){
 echo "normal method";
echo "your php version: ".PHP_VERSION;
$c = new a;


your php version: 5.5.20normal method


namespace Foo;
class a {
 public function a(){
 echo "normal method";
echo "your php version: ".PHP_VERSION;
$c = new a;


your php version: 5.5.20(没有报错)