IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP Discussion :

RegEx : besoin d'aide


Sujet :

ASP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Septembre 2007
    Messages
    4
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2007
    Messages : 4
    Par défaut RegEx : besoin d'aide
    Bonjour.

    Merci d'avance pour toute réponse.

    Voici mon problème : j'essaie de de lire un fichier html contenant des balises ASP. Je l'analyse en me servant d'expressions régulières.

    J'utilise les expressions régulières suivantes :
    - trouver tout texte précédent la première balise ASP :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    "^([\s\S]*?)<" & Chr(37)
    - trouver le code ASP :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    "<" & Chr(37) & "([\s\S]*?)" & Chr(37) & ">"
    - trouver tout texte entre des balises ASP :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Chr(37) & ">([\s\S]*?)<" & Chr(37)
    Maintenant, je n'arrive pas à trouver la dernière partie : tout texte suivant la dernière balise ASP.

    J'ai trouvé l'expression suivante :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Chr(37) & ">[\s\S]*" & Chr(37) & ">([\s\S]*?)$"
    mais elle prend le dès la première balise ASP fermante, ce qui ne serait pas très fonctionnel (je suppose) si le fichier faisait plusieurs milliers de lignes...

    Bien sûr, je pourrais me servir d'un simple InStrRev() pour résoudre le problème. Mais j'essaie aussi d'en apprendre plus dans la foulée

    Merci encore pour toute aide les gars.

    Voici comment se présente mon fichier html :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
     
    <head>
     
    <title>template test</title>
     
    </head>
     
    <body>
     
    <%
    Response.Write "Hello 1"
    Response.Write "<br />" & vbCrLf
    %>
     
    <foreach variable="objDictionary1">
     
    	<objDictionary1.index>) <objDictionary1.key> : <objDictionary1.value><br />
     
    </foreach>
     
    <%
    Response.Write "Hello 2"
    Response.Write "<br />" & vbCrLf
    %>
     
    <foreach variable="objDictionary2">
     
    	<objDictionary2.index>) <objDictionary2.key> : <objDictionary2.value><br />
     
    </foreach>
     
    <foreach variable="objDictionary3">
     
    	<objDictionary3.index>) <objDictionary3.key> : <objDictionary3.value><br />
     
    <%
    Response.Write "Hello 3"
    Response.Write "<br />" & vbCrLf
    %>
     
    </foreach>
     
    <foreach variable="objDictionary4">
     
    	<objDictionary4.index>) <objDictionary4.key> : <objDictionary4.value><br />
     
    </foreach>
     
    <%
    Response.Write "Hello 4"
    Response.Write "<br />" & vbCrLf
    %>
     
    </body>
    </html>

  2. #2
    Expert confirmé
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Par défaut
    Salut,

    Je te laisse le code suivant (qui n'est pas de moi). Il permet d'afficher une page web qui va lire un script ASP et le colorer. Cela devrait t'aider.

    A+
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    <% '******************************************************************************
    ' ********************** DO NOT DELETE ****************************************
    '
    ' COPYRIGHT NOTICE: Copyright 1999 Jon M. Gohr, NetTech Development Inc.
    '
    ' This code is free for non-commercial use. Any commercial usage or 
    ' duplication requires a licensing agreement from the author who may be 
    ' contacted at the following email address: jongohr@yahoo.com
    '
    ' The author assumes no responsibility for any damage caused by the 
    ' proper or inproper use of this code.
    '
    ' ********************** DO NOT DELETE ****************************************
    '******************************************************************************
    %>
     
    <% Class cBuffer
        Private m_objFSO, m_objFile, m_objDict
        Private m_strPathToFile, m_TableBGColor, m_StartTime
        Private m_EndTime, m_LineCount, m_intKeyMin, m_intKeyMax
        Private m_CodeColor, m_CommentColor, m_StringColor, m_TabSpaces
     
        '**************************************************************************
        ' BEGIN EVENT HANDLERS
        '**************************************************************************
        Private Sub Class_Initialize()
            ' Set the intial table background color
            TableBGColor = "silver"
            ' Set the intial color for the code keywords
            CodeColor = "Blue"
            ' Set the intial color for comments
            CommentColor = "Green"
            ' Set the intial color for quoted strings
            StringColor = "Borwn"
            ' Set the number of spaces we will use to replace tab characters
            TabSpaces = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
            ' Set the File Path to an empty string
            PathToFile = ""
     
            ' Zero these out, hopefully their use is obvious?
            m_StartTime = 0
            m_EndTime = 0
            m_LineCount = 0
     
            ' 2 is the size of the smallest known keyword
            KeyMin = 2
            ' 8 is the size of the largest known keyword
            KeyMax = 8
     
            ' Create an instance of the dictionary object
            Set m_objDict = server.CreateObject("Scripting.Dictionary")
            ' Set the dictionary object compare mode to text
            m_objDict.CompareMode = 1
     
            CreateKeywords
     
            ' Create an instance of the FileSystemObject
            Set m_objFSO = server.CreateObject("Scripting.FileSystemObject")
        End Sub
     
        Private Sub Class_Terminate()
            ' Destroy the objects created in the intialize event
            Set m_objDict = Nothing
            Set m_objFSO = Nothing
        End Sub
     
        '**************************************************************************
        ' END EVENT HANDLERS
        '**************************************************************************
     
        '**************************************************************************
        ' BEGIN PROPERTIES
        '**************************************************************************
     
        ' PROPERTIES WITH SOME PUBLIC EXPOSURE ************************************
        Public Property Let CodeColor(inColor)
            m_CodeColor = "<font color=" & inColor & "><Strong>"
        End Property
        Private Property Get CodeColor()
            CodeColor = m_CodeColor
        End Property
     
        Public Property Let CommentColor(inColor)
            m_CommentColor = "<font color=" & inColor & ">"
        End Property
        Private Property Get CommentColor()
            CommentColor = m_CommentColor
        End Property
     
        Public Property Let StringColor(inColor)
            m_StringColor = "<font color=" & inColor & ">"
        End Property
        Private Property Get StringColor()
            StringColor = m_StringColor
        End Property
     
        Public Property Let TabSpaces(inSpaces)
            m_TabSpaces = inSpaces
        End Property
        Private Property Get TabSpaces()
            TabSpaces = m_TabSpaces
        End Property
     
        Public Property Let TableBGColor(inColor)
            m_TableBGColor = inColor
        End Property
     
        Private Property Get TableBGColor()
            TableBGColor = m_TableBGColor
        End Property
     
        Public Property Get ProcessingTime()
            ProcessingTime = Second(m_EndTime - m_StartTime)
        End Property
     
        Public Property Get LineCount()
            LineCount = m_LineCount
        End Property
     
        Public Property Get PathToFile()
            PathToFile = m_strPathToFile
        End Property
        Public Property Let PathToFile(inPath)
            m_strPathToFile = inPath
        End Property
     
        ' PRIVATE PROPERTIES ******************************************************
        Private Property Let KeyMin(inMin)
            m_intKeyMin = inMin
        End Property
        Private Property Get KeyMin()
            KeyMin = m_intKeyMin
        End Property
        Private Property Let KeyMax(inMax)
            m_intKeyMax = inMax
        End Property
        Private Property Get KeyMax()
            KeyMax = m_intKeyMax
        End Property
     
        '**************************************************************************
        ' END PROPERTIES
        '**************************************************************************
     
        '**************************************************************************
        ' BEGIN METHODS
        '**************************************************************************
     
        ' subroutine to add all of the known language keywords to the dictionary
        Private Sub CreateKeywords()
            m_objDict.Add "abs", "Abs"
            m_objDict.Add "and", "And"
            m_objDict.Add "array", "Array"
            m_objDict.Add "call", "Call"
            m_objDict.Add "case", "Case"
            m_objDict.Add "cbool", "CBool"
            m_objDict.Add "cbyte", "CByte"
            m_objDict.Add "ccur", "CCur"
            m_objDict.Add "cdate", "CDate"
            m_objDict.Add "cdbl", "CDbl"
            m_objDict.Add "cint", "CInt"
            m_objDict.Add "class", "Class"
            m_objDict.Add "clng", "CLng"
            m_objDict.Add "const", "Const"
            m_objDict.Add "csng", "CSng"
            m_objDict.Add "cstr", "CStr"
            m_objDict.Add "date", "Date"
            m_objDict.Add "dim", "Dim"
            m_objDict.Add "do", "Do"
            m_objDict.Add "each", "Each"
            m_objDict.Add "else", "Else"
            m_objDict.Add "elseif", "ElseIf"
            m_objDict.Add "empty", "Empty"
            m_objDict.Add "end", "End"
            m_objDict.Add "eqv", "Eqv"
            m_objDict.Add "erase", "Erase"
            m_objDict.Add "error", "Error"
            m_objDict.Add "exit", "Exit"
            m_objDict.Add "explicit", "Explicit"
            m_objDict.Add "false", "False"
            m_objDict.Add "fix", "Fix"
            m_objDict.Add "for", "For"
            m_objDict.Add "function", "Function"
            m_objDict.Add "get", "Get"
            m_objDict.Add "global", "Global"
            m_objDict.Add "if", "If"
            m_objDict.Add "imp", "Imp"
            m_objDict.Add "int", "Int"
            m_objDict.Add "is", "Is"
            m_objDict.Add "lbound", "LBound"
            m_objDict.Add "len", "Len"
            m_objDict.Add "let", "Let"
            m_objDict.Add "loop", "Loop"
            m_objDict.Add "mod", "Mod"
            m_objDict.Add "new", "New"
            m_objDict.Add "next", "Next"
            m_objDict.Add "not", "Not"
            m_objDict.Add "nothing", "Nothing"
            m_objDict.Add "null", "Null"
            m_objDict.Add "on", "On"
            m_objDict.Add "option", "Option"
            m_objDict.Add "or", "Or"
            m_objDict.Add "private", "Private"
            m_objDict.Add "property", "Property"
            m_objDict.Add "public", "Public"
            m_objDict.Add "redim", "Redim"
            m_objDict.Add "resume", "Resume"
            m_objDict.Add "select", "Select"
            m_objDict.Add "set", "Set"
            m_objDict.Add "sgn", "Sgn"
            m_objDict.Add "string", "String"
            m_objDict.Add "sub", "Sub"
            m_objDict.Add "then", "Then"
            m_objDict.Add "true", "True"
            m_objDict.Add "ubound", "UBound"
            m_objDict.Add "wend", "Wend"
            m_objDict.Add "while", "While"
            m_objDict.Add "with", "With"
            m_objDict.Add "xor", "Xor"
        End Sub
     
        ' Simple function to return the smaller of two numbers
        Private Function Min(x, y)
            Dim tempMin
            If x < y Then tempMin = x Else tempMin = y
            Min = tempMin
        End Function
     
        ' simple function to return the larger of two numbers
        Private Function Max(x, y)
            Dim tempMax
            If x > y Then tempMax = x Else tempMax = y
            Max = tempMax
        End Function
     
        ' Public method to add keywords to the dictionary object
        Public Sub AddKeyword(inKeyword, inToken)
            KeyMin = Min(Len(inKeyword), KeyMin)
            KeyMax = Max(Len(inKeyword), KeyMax)
     
            m_objDict.Add LCase(inKeyword), inToken
        End Sub
     
        ' This is the primary method of the class.
        Public Sub ParseFile(blnOutputHTML)
            Dim m_strReadLine, tempString, blnInScriptBlock, blnGoodExtension, i
            Dim blnEmptyLine
     
            ' zero out the line count
            m_LineCount = 0
     
            ' Check the length of the PathToFile property.
            If Len(PathToFile) = 0 Then
                Err.Raise 5, "cBuffer: PathToFile Length Zero"
                Exit Sub
            End If
     
            ' Check the file extension
            Select Case LCase(Right(PathToFile, 3))
                Case "asp", "inc", "html", "asa", "htm"
                    blnGoodExtension = True
                Case Else
                    blnGoodExtension = False
            End Select
     
            If Not blnGoodExtension Then
                Err.Raise 5, "cBuffer: File extension not asp or inc"
                Exit Sub
            End If
     
            ' Open the file
            Set m_objFile = m_objFSO.OpenTextFile(server.MapPath(PathToFile))
     
            ' Start the outside table which will contain all the output
            Response.Write "<table nowrap bgcolor=" & TableBGColor & " cellpadding=0 cellspacing=0>"
            Response.Write "<tr><td><PRE>"
     
            ' Grab the time at the start of processing
            m_StartTime = Time()
     
            ' loop and read the file a line at a time
            Do While Not m_objFile.AtEndOfStream
                m_strReadLine = m_objFile.ReadLine
     
                ' Because of the line conversion we do below we need to catch blank lines up here right away.
                blnEmptyLine = False
                If Len(m_strReadLine) = 0 Then
                    blnEmptyLine = True
                End If
     
                ' Replace all the tab characters with spaces
                m_strReadLine = Replace(m_strReadLine, vbTab, TabSpaces)
                ' Increment the line count
                m_LineCount = m_LineCount + 1
                ' Trim all the spaces from the left side of the line
                ' so we can start doing evaluation of the content of the line
                tempString = LTrim(m_strReadLine)
     
                ' Check for the top script line that set's the default script language
                ' for the page.
                If left( tempString, 3 ) = Chr(60) & "%@" And right(tempString, 2) = "%" & Chr(62) Then
                    Response.Write "<table><tr bgcolor=yellow><td>"
                    Response.Write server.HTMLEncode(m_strReadLine)
                    Response.Write "</td></tr></table>"
                    blnInScriptBlock = False
                ' Check for an opening script tag
                ElseIf Left(tempString, 2) = Chr(60) & "%" Then
                    ' Check for a closing script tag on the same line
                    If right( RTrim(tempString), 2 ) = "%" & Chr(62) Then
                        Response.Write "<table><tr><td bgcolor=yellow><%</td>"
                        Response.Write "<td>"
                        Response.Write CharacterParse(mid(m_strReadLine, 3, Len(m_strReadLine) - 4))
                        Response.Write "</td>"
                        Response.Write "<td bgcolor=yellow>%&gt;</td></tr></table>"
                        blnInScriptBlock = False
                    Else
                        Response.Write "<table><tr bgcolor=yellow><td>&lt;%</td></tr></table>"
                        ' We've got an opening script tag so set the flag to true so
                        ' that we know to start parsing the lines for keywords/comments
                        blnInScriptBlock = True
                    End If
                Else
                    If blnInScriptBlock Then
                        If blnEmptyLine Then
                            Response.Write vbCrLf
                        Else
                            If right(tempString, 2) = "%" & Chr(62) Then
                                Response.Write "<table><tr bgcolor=yellow><td>%&gt;</td></tr></table>"
                                blnInScriptBlock = False
                            Else
                                if instr(lcase(m_strReadLine), "class ") > 0 then
                                    Response.Write CharacterParse(m_strReadLine) & vbCrLf
                                elseif instr(lcase(m_strReadLine), "sub ") > 0 then
                                    Response.Write CharacterParse(m_strReadLine) & vbCrLf
                                elseif instr(lcase(m_strReadLine), "function ") > 0 then
                                    Response.Write CharacterParse(m_strReadLine) & vbCrLf
                                elseif instr(lcase(m_strReadLine), "property ") > 0 then
                                    Response.Write CharacterParse(m_strReadLine) & vbCrLf
                                end if
                            End If
                        End If
                    Else
                        If blnOutputHTML Then
                            If blnEmptyLine Then
                                Response.Write vbCrLf
                            Else
                                Response.Write server.HTMLEncode(m_strReadLine) & vbCrLf
                            End If
                        End If
                    End If
                End If
            Loop
     
            ' Grab the time at the completion of processing
            m_EndTime = Time()
     
            ' Close the outside table
            Response.Write "</PRE></td></tr></table>"
     
            ' Close the file and destroy the file object
            m_objFile.close
            Set m_objFile = Nothing
        End Sub
     
        ' This function parses a line character by character
        Private Function CharacterParse(inLine)
            Dim charBuffer, tempChar, i, outputString
            Dim insideString, workString, holdChar
     
            insideString = False
            outputString = ""
     
            For i = 1 to Len(inLine)
                tempChar = mid(inLine, i, 1)
                Select Case tempChar
                    Case " "
                        If Not insideString Then
                            charBuffer = charBuffer & " "
                            If charBuffer <>" "  Then
                                If left(charBuffer, 1) = " " Then outputString = outputString & " "
     
                                ' Check for a 'rem' style comment marker
                                If LCase(Trim(charBuffer)) = "rem" Then
                                    outputString = outputString & CommentColor
                                    outputString = outputString & "REM"
                                    workString = mid( inLine, i, Len(inLine))
                                    workString = replace(workString, "&lt;", "&lt;")
                                    workString = replace(workString, "&gt;", "&gt;")
                                    outputString = outputString & workString & "</font>"
                                    charBuffer = ""
                                    Exit For
                                End If
     
                                outputString = outputString & FindReplace(Trim(charBuffer))
                                If right(charBuffer, 1) = " " Then outputString = outputString & " "
                                charBuffer = ""
                            End If
                        Else
                            outputString = outputString & " "
                        End If
                    Case "("
                        If left(charBuffer, 1) = " " Then
                            outputString = outputString & " "
                        End If
                        outputString = outputString & FindReplace(Trim(charBuffer)) & "("
                        charBuffer = ""
                    Case Chr(60)
                        outputString = outputString & "&lt;"
                    Case Chr(62)
                        outputString = outputString & "&gt;"
                    Case Chr(34)
                        ' catch quote chars and flip a boolean variable to denote that
                        ' whether or not we're "inside" a quoted string
                        insideString = Not insideString
                        If insideString Then
                            outputString = outputString & StringColor
                            outputString = outputString & """"
                        Else
                            outputString = outputString & """"
                            outputString = outputString & "</font>"
                        End If
                    Case "'"
                        ' Catch comments and output the rest of the line
                        ' as a comment IF we're not inside a string.
                        If Not insideString Then
                            outputString = outputString & CommentColor
                            workString = mid( inLine, i, Len(inLine))
                            workString = replace(workString, "&lt;", "&lt;")
                            workString = replace(workString, "&gt;", "&gt;")
                            outputString = outputString & workString
                            outputString = outputString & "</font>"
                            Exit For
                        Else
                            outputString = outputString & "'"
                        End If
                    Case Else
                        ' We've dealt with special case characters so now
                        ' we'll begin adding characters to our outputString
                        ' or charBuffer depending on the state of the insideString
                        ' boolean variable
                        If insideString Then
                            outputString = outputString & tempChar
                        Else
                            charBuffer = charBuffer & tempChar
                        End If
                End Select
            Next
     
            ' Deal with the last part of the string in the character buffer
            If Left(charBuffer, 1) = " " Then
                outputString = outputString & " "
            End If
            ' Check for closing parentheses at the end of a string
            If right(charBuffer, 1) = ")" Then
                charBuffer = Left(charBuffer, Len(charBuffer) - 1)
                CharacterParse = outputString & FindReplace(Trim(charBuffer)) & ")"
                Exit Function
            End If
     
            CharacterParse = outputString & FindReplace(Trim(charBuffer))
        End Function
     
        ' return true or false if a passed in number is between KeyMin and KeyMax
        Private Function InRange(inLen)
            If inLen >= KeyMin And inLen <= KeyMax Then
                InRange = True
                Exit Function
            End If
            InRange = False
        End Function
     
        ' Evaluate the passed in string and see if it's a keyword in the
        ' dictionary. If it is we will add html formatting to the string
        ' and return it to the caller. Otherwise just return the same
        ' string as was passed in.
        Private Function FindReplace(inToken)
            ' Check the length to make sure it's within the range of KeyMin and KeyMax
            If InRange(Len(inToken)) Then
                If m_objDict.Exists(inToken) Then
                    FindReplace = CodeColor & m_objDict.Item(inToken) & "</Strong></Font>"
                    Exit Function
                End If
            End If
            ' Keyword is either too short or too long or doesn't exist in the
            ' dictionary so we'll just return what was passed in to the function 
            FindReplace = inToken
        End Function
     
        '**************************************************************************
        ' END METHODS
        '**************************************************************************
    End Class
    %>
    "Winter is coming" (ma nouvelle page d'accueil)

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Septembre 2007
    Messages
    4
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2007
    Messages : 4
    Par défaut changement de méthode
    Salut Immobilis.

    Tout d'abord merci pour ta réactivité et ton coup de pouce, c'est sympa

    Je t'avoue qu'après avoir posté ma requête, j'ai pensé à changer de méthode. Je serais toujours curieux d'apprendre à effectuer la requête RegExp correcte mais je ne suis pas bloqué par ça et peut continuer.

    Pour info, je suis en train de créer un lecteur de template web. Au niveau fonctionnalités :
    - variables <variable>
    - boucle <foreach> sur des variables ASP
    - boucle <for> sur des variables ASP
    - code ASP intégré

    Enfin la syntaxe changera peut-être mais voilli le programme.

    Merci encore !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Besoin d'aide sur une regex
    Par El_touristo dans le forum Langage
    Réponses: 3
    Dernier message: 19/11/2010, 19h32
  2. Besoin d'aide pour écrire une regex
    Par kao98 dans le forum Général Python
    Réponses: 4
    Dernier message: 05/03/2010, 16h59
  3. Besoin d'aide pour un regex
    Par chris81 dans le forum Windows Forms
    Réponses: 4
    Dernier message: 26/09/2008, 15h02
  4. [RegEx] Besoin d'aide pour une regex
    Par vallica dans le forum Langage
    Réponses: 3
    Dernier message: 20/09/2006, 09h50
  5. [Regex] besoin d'aide sur des motifs
    Par Oluha dans le forum Général JavaScript
    Réponses: 13
    Dernier message: 25/11/2005, 12h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo