Pattern 등록정보

정규 표현식 패턴을 정의합니다.

등록정보 사용법:

구문: Object.Pattern = "<PATTERN STRING>"

예:

regExpObj.Pattern = "^\d{4}_\d{6}$" ' Match strings in the format 1234_567890

regExpObj.Pattern = "\b\d{2}/\d{2}/\d{4}\b" 'Matches dates in the MM/DD/YYYY format

예:
Dim regex, inputText
Set regex = CreateObject("VBScript.RegExp")
regex.Pattern = "^\d{4}_\d{6}$"   ' Match strings in the format 1234_567890
inputText = "1234_567890"
' Check if the inputText matches the pattern
If regex.Test(inputText) Then
    'Valid Format Related Coding
Else
    'Invalid format Related Coding
End If

위의 코드에서 ^\d{4}_\d{6}$ 패턴은 inputText가 정확히 4자리 형식이어야 하고 그 뒤에 밑줄(_)과 6자리 숫자가 오도록 합니다. inputText가 패턴과 일치하는 경우 적합한 형식 섹션 코드 플로우가 트리거됩니다. 그렇지 않으면 부적합한 형식 관련 코드 플로우에 포함됩니다.