Regular Expression!!!

Source: Internet
Author: User
Tags expression engine

The regular expression (Regular expression) uses a single string to describe and match a series of strings that conform to a certain syntactic rule. In many text editors, regular expressions are often used to retrieve and replace text that conforms to a pattern. Many programming languages support string manipulation using regular expressions, and Perl has built a powerful regular expression engine pcre, the concept of regular expressions that was initially popularized by the Unix tool software sed grep.

where "\" in the regular expression means escape, this is a pit, the regular expression is too early to contact, but because it is too abstract, so has not been to the mind, and then was the pit ... In the Nginx configuration file, there are:

  1 server{2 3 listen 8054;      4 root/home/users********;      5 Access_log/home/users/***/var/logs/nginx/faren.log Main;      6 error_log/home/users/***/var/logs/nginx/faren_error.log;      7 index index.php;        8 9   location/{  ten include     Fastcgi_params;     One by one fastcgi_param script_filename $document _root/matrix/index.php;     Fastcgi_param Request_uri/matrix/faren$fastcgi_script_name;     Fastcgi_pass 127.0.0.1:10053;     Fastcgi_connect_timeout 5s;     5s Fastcgi_read_timeout;     5s Fastcgi_send_timeout; +   location ~ \. (     Js|css|jpg|jpeg|png|gif|ico) $ {  root/home/users/*********; +}  

Regular expression is included in the configuration on line 19th above. Here, write about the resource identifier syntax for location in Nginx configuration:

The URI, which is the Uniform Resource identifier, is the Uniform Resource identifier used to uniquely identify a resource. The URL is a Uniform Resource Locator, a Uniform Resource locator, which is a specific URI that the URL can use to identify a resource and also how to locate the resource. and Urn,uniform resource Name, unified resource naming, is the name to identify resources, such as Mailto:[email protected]. That is, URIs define uniform resource identities in an abstract, high-level concept, whereas URLs and urns are specific resource identities. URLs and urns are all a kind of URI.


Here the location can be a literal string or regular expression, just the above example contains two, the following to elaborate on Nginx when received an HTTP request, his processing flow:

  resolve incoming HTTP requests ------->>>>

  Find the server level within the HTTP level of the configuration file to find the appropriate domain name (because there may be multiple virtual hosts) ————— >>>>

  go to the server level find the appropriate URI based on the URL of the request ———— >>>>

  Depending on the situation if it is static then nginx processing, if it is. php to fastcgi.

When looking for an appropriate URI, follow these rules:

First, the text string in the search configuration file indicates that the URI has a match, and then searches for the URI represented by the regular expression, if the hit then presses the URI, and if no hit, the result of matching the text character.

Syntax for representing URIs with literal strings and regular expressions see: Http://wiki.nginx.org/HttpCoreModule#location

Regular Expression!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.