To ask a related question, regex matches the name of the database in which the SQL statement is created.

Source: Internet
Author: User
To ask a question, what is the name of the database where the regular expression matches the SQL statement used to create the database? In all cases, the names of the SQL statements that can be used to create a database must be matched. The name may not have '', there may be no spaces, and there may be no modifier keywords ..., /create \ s + database \ s + (\ w +)/is name may not have ''. is there a question: does the regular expression match the name of the database used to create the database SQL?
In all cases, the names of the SQL statements that can be used to create a database must be matched.
The name may not have '', there may be no spaces, and there may be no modifier keywords...



------ Solution --------------------
/Create \ s + database \ s + (\ w +)/is

The name may not have '', and there may be no spaces
Impossible
------ Solution --------------------
PHP code
  ------ Solution --------------------
PHP code
    ------ Solution --------------------
Add the symbol in the name to the brackets. for example, you can say () [\ w @ # '()].
I can only ensure that the database name appears at the same time or does not appear at the same time, and cannot control the number of 'in it
------ Solution --------------------
Discussion
That is to say, you can use any character in the ''name.

The name can only be separated by letters and numbers with a space.

------ Solution --------------------
The string can be represented by [: punct:], and [: punct:] represents punctuation characters similar to [: alnum:] [: space:]... each represents several types of strings
You can modify it as follows:
PHP code
Preg_match_all ('/CREATE \ s + DATABASE \ s * ([' \ '"])?) ([\ W [: punct:] +) \ 2 \ s ?) /Is ', $ SQL, $ matchs );
------ Solution --------------------
Try
PHP code
$ Databases = <
        ------ Solution --------------------
None of the above. the ''intermediate ''must be an even number .. This is troublesome.
------ Solution --------------------
Discussion


That's right. ''Intermediate ''is an even number. If it is a singular number, it indicates a problematic SQL statement.

The 'AAA' above you cannot match the 'BBB.

Reference:

None of the above. the ''intermediate ''must be an even number .. This is troublesome.

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.