Series 17: How to Use XSL and regular expressions to verify data Validity
XSL is gradually becoming a role in XML similar to SQL in database design.
Although Microsoft's XSL only implements some of the functions
However, you can implement very complex queries.
Although the current XSL is only a pure text and string-based method
Query Language
In the example described below, we will use a lot of string searches in the text,
You will find that a large part of data processing in XML must be queried in text.
This is a very popular feature in the compilation of XSL.
Because of this, you should know how to use some regular expressions.
Introduction to Regular Expressions
Most regular expressions come from the Unix world.
In Unix, almost all programming languages are centered around regular expressions (such as Perl, Python, and Tcl)
However, it is strange that regular expressions seem to have recently been used in the Windows series,
In particular, a large number of scripts, such as JavaScript and VBScript,
Although you can also use them in Visual Basic or Java, it seems that they are
Scripting languages are more attractive. For this reason, it seems that regular expressions are rarely used.
Using Regular Expressions, you can create a matching template (pattern) based on the content you want to query)
Once you create a template using a regular expression, you can use it to test your string,
Using it can accomplish many functions:
For example, to determine whether a string is in another string (or where it is in another string)
For example, replace another string with a string.
For example, return the list of all strings meeting the template conditions.
For example... And so on.
I have introduced the basic concepts of regular expressions. For details about the Regular Expression and Its syntax, refer to MSDN and
Help in JavaScript.
If you want to reference a Regular expression in VB, You need to reference "Microsoft VBScript Regular Expressions" in the project ". However, if you use a script, it is unnecessary because it is already
The internal object is for your reference.
Of course, you need to install IE4 or above on your machine.
This object (in JavaScript) is called RegExp
Let the Code explain the problem. Now, suppose you want to check whether a document contains a specific
String (for example, "regular expressions ")
For the code, see:
The code is written in VB.
Public Function IsTermInDocument (filePath As String ,_
Expr As String) As Boolean