asp 정규 표현 식
3211 단어 정규 표현 식
a
=
"
1,2,3,7_UP,sss
"
Set
myRegExp
=
New
RegExpmyRegExp.Pattern
=
"
(.*)(\d)_UP(.*)
"
set
matchs
=
myRegExp.execute(a)response.Write(matchs(
0
).SubMatches.count
&
"
"
)response.write(matchs(
0
).SubMatches(
0
)
&
"
"
)response.write(matchs(
0
).SubMatches(
1
)
&
"
"
)response.write(matchs(
0
).SubMatches(
2
)
&
"
"
)
'
결 과 는:
'
3
'
1,2,3,
'
7
'
,sss
원문 은 이렇게 말한다. "
The MatchCollection object returned by the RegExp.Execute method is a collection of Match objects. It has only two read-only properties. The Count property indicates how many matches the collection holds. The Item property takes an index parameter (ranging from zero to Count-1), and returns a Match object. The Item property is the default member, so you can write MatchCollection(7) as a shorthand to MatchCollection.Item(7).
The easiest way to process all matches in the collection is to use a For Each construct, e.g.:
' Pop up a message box for each match
Set myMatches = myRegExp.Execute(subjectString)
For Each myMatch in myMatches
msgbox myMatch.Value, 0, "Found Match"
Next
The Match object has four read-only properties. The FirstIndex property indicates the number of characters in the string to the left of the match. If the match was found at the very start of the string, FirstIndex will be zero. If the match starts at the second character in the string, FirstIndex will be one, etc. Note that this is different from the VBScript Mid function, which extracts the first character of the string if you set the start parameter to one. The Length property of the Match object indicates the number of characters in the match. The Value property returns the text that was matched.
The SubMatches property of the Match object is a collection of strings. It will only hold values if your regular expression has capturing groups . The collection will hold one string for each capturing group. The Count property indicates the number of string in the collection. The Item property takes an index parameter, and returns the text matched by the capturing group. The Item property is the default member, so you can write SubMatches(7) as a shorthand to SubMatches.Item(7). Unfortunately, VBScript does not offer a way to retrieve the match position and length of capturing groups.
"주 소 는: http://www.regular-expressions.info/vbscript.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
awk 상용 명령awk 는 모든 입력 줄 을 하나의 기록 으로 인식 하고 그 줄 의 모든 단어 도 메 인 을 하나의 필드 로 인식 합 니 다. ARGC 명령 줄 에 awk 스 크 립 트 가 들 어 오 는 매개...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.