0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

文字列存在チェック

Last updated at Posted at 2025-04-22

文字列内に指定文字列が存在するかチェックする

文字列存在チェック

引数情報指定

'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' 文字列存在チェック
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' 文字列存在チェック(引数情報指定)
'------------------------------------------------------------------------------
Public Function F_String_Check_Inf( _
        ByRef aArgInf As T_STRING_ARG_CHK_INF) As Boolean
    Dim wkRtn As Boolean
    
    Dim wkTmpAryAry As Variant
    Dim wkTmpPos As Long
    
    If F_String_GetSearchInfArray_Inf(wkTmpAryAry, aArgInf) <> True Then
        Exit Function
    End If
    
    With aArgInf
        '先頭一致指定アリの場合
        If M_Common.F_CheckBitOn(.SrchSpec, E_STRING_SPEC_POS_START) = True Then
            wkTmpPos = LBound(wkTmpAryAry)
            
            '先頭でなければ終了
            If wkTmpAryAry(wkTmpPos)(E_STRING_IDX_SRCH_INF_POS_START) > 1 Then
                Exit Function
            End If
        End If
        '終端一致指定アリの場合
        If M_Common.F_CheckBitOn(.SrchSpec, E_STRING_SPEC_POS_END) = True Then
            wkTmpPos = UBound(wkTmpAryAry)
            
            '終端でなければ終了
            If (wkTmpAryAry(wkTmpPos)(E_STRING_IDX_SRCH_INF_POS_START) + wkTmpAryAry(wkTmpPos)(E_STRING_IDX_SRCH_INF_LENGTH) - 1) < _
                    Len(.Str) Then
                Exit Function
            End If
        End If
    End With
    
    F_String_Check_Inf = True
End Function

引数指定

'------------------------------------------------------------------------------
' 文字列存在チェック(引数指定)
'------------------------------------------------------------------------------
Public Function F_String_Check( _
        ByVal aStr As String, ByVal aSearch As String, _
        Optional ByVal aSrchSpec As E_STRING_SPEC = E_STRING_SPEC_POS_MID) As Boolean
    Dim wkArgInf As T_STRING_ARG_CHK_INF: wkArgInf = G_String_InitArgChkInf()
    
    With wkArgInf
        .Str = aStr
        .Search = aSearch
        .SrchSpec = aSrchSpec
    End With
    
    F_String_Check = F_String_Check_Inf(wkArgInf)
End Function

単語存在チェック(引数指定)

'------------------------------------------------------------------------------
' 単語存在チェック(引数指定)
'------------------------------------------------------------------------------
Public Function F_String_CheckWord( _
        ByVal aStr As String, ByVal aSearch As String, _
        Optional ByVal aChkPtn As String = D_STRING_CHECKWORD, _
        Optional ByVal aSrchSpec As E_STRING_SPEC = E_STRING_SPEC_POS_MID, _
        Optional ByVal aChkPtnSpec As E_STRING_SPEC = E_STRING_SPEC_POS_MATCH) As Boolean
    Dim wkRtn As Boolean
    
    Dim wkArgInf As T_STRING_ARG_CHK_INF: wkArgInf = G_String_InitArgChkInf()
    Dim wkTmpAryAry As Variant
    
    With wkArgInf
        .Str = aStr
        .Search = aSearch
        .SrchSpec = aSrchSpec
        
        .ChkPtn = aChkPtn
        .ChkPtnSpec = aChkPtnSpec
    End With
    
    F_String_CheckWord = F_String_Check_Inf(wkArgInf)
End Function
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?