2015-05-01 43 views

回答

0

不知道你想要什么,如果你想检查一个字符串开头字母,之后可能包含字母或数字,你可以使用普通的expressons

Function IsVar(txt as string) as Boolean 
    'txt ="id45" 

IsVar = False 

Dim re1 As String 
re1 ="((?:[a-z][a-z0-9_]*))" 

Dim r As New RegExp 
    r.Pattern = re1 
    r.IgnoreCase = True 

    bX = re.Test(sSendLine) 
    If bX = True Then 
IsVar = True 
    End If 

End Function 

基本上常规的指令“说:”

[a-z] match a single character present in the list 
    a-z a single character in the range between a and z (case sensitive) 
[a-z0-9_]* match a single character present in the list 
    a-z a single character in the range between a and z (case sensitive) 
    0-9 or a single character in the range between 0 and 9 
    _ or the character _ (underscore) 
* do the previous match from zero to unlimited times (as many times as possible) [greedy] 

如果我们应该有一个字符串“id45”。

the first character is an I -- first instruction successful (next) 
character 2 = d    -- second instruction successful (repeat) 
character 3 = 4    -- second instruction successful (repeat) 
character 4 = 5    -- second instruction successful (repeat) 
no more characters   -- return true 

如果你不想和下划线,只需取出正则表达式中的下划线即可。

希望这有助于 查理

相关问题