VB中的Like运算符的问题2

alike"<?>"它的意思是判断字符串a是不是三个字,并且是以"<"开头以">"结束.一般情况下,like是比较费时的,它的运算没有你直接将字符串折分出来用=来比较快,... a like "<?>"它的意思是判断字符串a是不是三个字,并且是以"<"开头以">"结束.一般情况下,like是比较费时的,它的运算没有你直接将字符串折分出来用=来比较快,但它可以进行更复杂的比较,比如判断在email数据串中,一段base64编码可以用这样的方式来匹配:strData Like "[?]B[?]*[?]="如果匹配,则对应*的部分就是base64编码部分了. 这段话怎么这么深澳啊?看不懂。什么base64编码? 展开
 我来答
匿名用户
2013-10-14
展开全部
like是用来比较两个字符串的运算符, 用法如下,(以下内容来自MSDN) Like Operator Used to compare two strings.Syntaxresult = string Like patternThe Like operator syntax has these parts:PartDescriptionresultRequired; any numeric variable.stringRequired; any string expression. patternRequired; any string expression conforming to the pattern-matching conventions described in Remarks.
RemarksIf string matches pattern, result is True; if there is no match, result is False. If either string or pattern is Null, result is Null.The behavior of the Like operator depends on the Option Compare statement. The default string-comparison method for each module is Option Compare Binary.Option Compare Binary results in string comparisons based on a sort order derived from the internal binary representations of the characters. Sort order is determined by the code page. In the following example, a typical binary sort order is shown:A < B < E < Z < a < b < e < z < �0�8 < �0�8 < �0�1 < à < ê < �0�3Option Compare Text results in string comparisons based on a case-insensitive, textual sort order determined by your system's locale. When you sort The same characters using Option Compare Text, the following text sort order is produced:(A=a) < (�0�8=à) < (B=b) < (E=e) < (�0�8=ê) < (Z=z) < (�0�1=�0�3)Built-in pattern matching provides a versatile tool for string comparisons. The pattern-matching features allow you to use wildcard characters, character lists, or character ranges, in any combination, to match strings. The following table shows the characters allowed in pattern and what they match:Characters in patternMatches in string?Any single character.*Zero or more characters.#Any single digit (0–9).[charlist]Any single character in charlist.[!charlist]Any single character not in charlist.
A group of one or more characters (charlist) enclosed in brackets ([ ]) can be used to match any single character in string and can include almost any character code, including digits.Note</b> To match the special characters left bracket ([), question mark (?), number sign (#), and asterisk (*), enclose them in brackets. The right bracket (]) can't be used within a group to match itself, but it can be used outside a group as an individual character.By using a hyphen (–) to separate the upper and lower bounds of the range, charlist can specify a range of characters. For example, [A-Z] results in a match if the corresponding character position in string contains any uppercase letters in the range A–Z. Multiple ranges are included within the brackets without delimiters.The meaning of a specified range depends on the character ordering valid at run time (as determined by Option Compare and the locale setting of the system the code is running on). Using the Option Compare Binary example, the range [A–E] matches A, B and E. With Option Compare Text, [A–E] matches A, a, �0�8, à, B, b, E, e. The range does not match �0�8 or ê because accented characters fall after unaccented characters in the sort order.Other important rules for pattern matching include the following: An exclamation point (!) at the beginning of charlist means that a match is made if any character except the characters in charlist is found in string. When used outside brackets, the exclamation point matches itself.

A hyphen (–) can appear either at the beginning (after an exclamation point if one is used) or at the end of charlist to match itself. In any other location, the hyphen is used to identify a range of characters.

When a range of characters is specified, they must appear in ascending sort order (from lowest to highest). [A-Z] is a valid pattern, but [Z-A] is not.

The character sequence [] is considered a zero-length string (""). In some languages, there are special characters in the alphabet that represent two separate characters. For example, several languages use the character "�0�3" to represent the characters "a" and "e" when they appear together. The Like operator recognizes that the single special character and the two individual characters are equivalent.When a language that uses a special character is specified in the system locale settings, an occurrence of the single special character in either pattern or string matches the equivalent 2-character sequence in the other string. Similarly, a single special character in pattern enclosed in brackets (by itself, in a list, or in a range) matches the equivalent 2-character sequence in string.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式