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
| <html>
<head>
<title>My HTML application</title>
<HTA:APPLICATION
APPLICATIONNAME="My HTML application"
ID="MyHTMLapplication"
VERSION="1.0"/>
</head>
<script language="VBScript">
Option Explicit
Dim FindSpaciChars
Dim strText , RegularExpressioN
Dim matches, MatchMsg, match
FindSpaciChars = "((?:([!$&-/:-@\[-^{-~£¨])\2+)*)([!$&-/:-@\[-^{-~£¨]?)"
Sub JobSpaciChars
strText = TxtSource.Value
Set RegularExpressioN = New RegExp
RegularExpressioN.Pattern = FindSpaciChars
RegularExpressioN.Global = True
Set matches = RegularExpressioN.Execute(strText)
If matches.Count > 0 Then
MatchMsg = matches.Count & " correspondance(s) trouvée(s)." & vbCrLf
For Each match In matches
If Not (match.SubMatches(2) = "") Then
MatchMsg = MatchMsg & "Correspondance trouvée """ & match.Submatches(2) & """ en position: " & match.FirstIndex + Len(match.SubMatches(0)) & vbCrLf
End If
Next
TxtMatchesSpaciChars.Value = MatchMsg
Else
MsgBox "No match", 0, "VBScript Regular Expression Tester"
End If
strText = RegularExpressioN.Replace(strText, "$1$3")
Set RegularExpressioN = Nothing
TxtReslutSpaciChars.Value = strText
End Sub
</script>
<body bgcolor="white">
</body>
<!-- LABEL TxtSource -->
<label for="LabSource">Saisir le texte à traiter:</label></P>
<!-- TEXTBOX TxtSource -->
<TEXTAREA type="text" name="TxtSource" Value ="" style="height:55px; width:500px">\-\\\*-****/Un test, Pourquoi faire? c'est fou ça! \****-*/// /</TEXTAREA></P>
<!-- BUTTON JobSpaciChars -->
<input type="button" value="Traitement des caractères minuscules isolés." onClick="JobSpaciChars" style="height:35px; width:500px"></P>
<!-- TEXTBOX TxtMatchesSpaciChars -->
<TEXTAREA type="text" name="TxtMatchesSpaciChars" Value ="" style="height:75px; width:500px"></TEXTAREA></P>
<!-- LABEL LabResultCharsMinChars -->
<label style="height:15px; width:500px" for="LabResultCharsMinChars">Caractères de la "Phase 1" remplacés:</label></P>
<!-- TEXTBOX TxtReslutSpaciChars -->
<TEXTAREA type="text" name="TxtReslutSpaciChars" Value ="" style="height:75px; width:500px"></TEXTAREA>
</html> |