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.