ASP中正規表示式的應用(一)

2021-03-31 11:37:23 字數 1232 閱讀 8659

結果是:"oranges are round, and oranges are juicy."

例:結果是:"twas the night before christmas..."

例:結果是:"**ith, john".

2、search

search通過正規表示式查詢相應的字串,只是判斷有無匹配的字串。如果查詢成功,search返回匹配串的位置,否則返回-1。

search(regexp)

3、match

match方法執行全域性查詢,查詢結果存放在乙個陣列裡。

例一:

顯示結果:chapter 3.4.5.1,chapter 3.4.5.1,.1

例二:顯示結果d, d.

四、示例

1 、判斷數字的正確性

<%@ language=vbscript %>

判斷數字的正確性

<%

dim strtemp

strtemp = cstr(request.form("inputstring"))

if strtemp = "" then strtemp = "0"

%>

原始字串

<%= strtemp %>

數字

<%=isnumeric(strtemp)%>

非負數字

<%=isunsignednumeric(strtemp)%>

整數

<%=isinteger(strtemp)%>

非負整數()

<%=isunsignedinteger(strtemp)%>

2、判斷email位址的正確性

<%

function isemail(strng)

isemail = false

dim regex, match

set regex = new regexp

regex.pattern = "^/w+((-/w+)|(/./w+))*/@[a-za-z0-9]+((/.|-)[a-za-z0-9]+)*/.[a-za-z0-9]+$"

regex.ignorecase = true

set match = regex.execute(strng)

if match.count then isemail= true

end function

%>

JS中正規表示式

js中正規表示式有幾種不同的使用方法,一些用法是通過字串物件來使用,另外一些通過正規表示式物件使用。一 regexp 正規表示式 的屬性和方法 1 屬性 regexp的例項有幾個唯讀的屬性 global表示是否為全域性匹配,igorecase表示是否忽略大小寫,multiline表示是否為多行匹配,...

PHP中正規表示式

正規表示式一般表示式的形式如下 love 其中位於 定界符之間的部分就是將要在目標物件中進行匹配的模式。為了能夠使使用者更加靈活的的定製模式內容,正規表示式提供了專門的 元字元 所謂元字元就是指那些表示式中具有特殊意義的字元,可以用來規定其前導字元 即在元字元前面的字元 在目標物件中的出現模式。較為...

python中正規表示式

python中正規表示式語法與linux中的相容 檢視正規表示式 python提供re模組,包含所有正規表示式的功能。由於python的字串本身也用 轉義,所以要特別注意 s abc 001 python的字串 對應的正規表示式字串變成 abc 001 建議使用python的r字首,就不用考慮轉義的...