Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionLike "*[Nothing]con[Nothing]*"?
toto = "con" or toto like ... etc ...PS : et juste pour le cas où j'aurais bien deviné ce que tu cherches à faire :
gros_mots = Array("con", "idiot", "abruti")
toto = "con, va! Tu ne sais pas, petit idiot, que pour aller s'abrutir " & _
"avec un autre abruti sur le continent, il ne faut pas être con."
For i = 0 To UBound(gros_mots)
M = gros_mots(i)
L = Len(M)
pos = InStr(toto, M)
Do While pos > 0
av = ""
If pos > 1 Then
av = Mid(toto, pos - 1, 1)
End If
ap = Mid(toto, pos + 0 + L, 1)
Select Case av
Case ",", " ", ".", ";", ""
Select Case ap
Case ",", " ", ".", ";", ""
Mid(toto, pos, L) = String(L, "*")
End Select
End Select
pos = InStr(pos + L, toto, M)
Loop
Next
MsgBox toto
Mid(toto, pos, L) = String(L, "*")par
toto = Replace(toto, av & M & ap, av & "#@$&|#" & ap, 1, 1)
Imports System.Text.RegularExpressions
Private listgrosmots As New List(Of String)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim txt As String
listgrosmots.Add("con")
listgrosmots.Add("abruti")
listgrosmots.Add("idiot")
listgrosmots.Add("idiote")
listgrosmots.Add("conne")
txt = "sur le continent ,il y a beaucoup de sorte de conniferes "
If DetectGrosMots(txt) Then
MessageBox.Show("gros mots")
Else
MessageBox.Show("pas de gros mots")
End If
txt = "con?? , va! Tu ne sais pas, petite idiote!!, que pour aller s'abrutir "
If DetectGrosMots(txt) Then
MessageBox.Show("gros mots")
Else
MessageBox.Show("pas de gros mots")
End If
txt = "Espece d'""4idiotes"" 10connes "
If DetectGrosMots(txt) Then
MessageBox.Show("gros mots")
Else
MessageBox.Show("pas de gros mots")
End If
txt = "ducon la joie "
If DetectGrosMots(txt) Then
MessageBox.Show("gros mots")
Else
MessageBox.Show("pas de gros mots")
End If
end sub
Private Function DetectGrosMots(ByVal texttocheck As String) As Boolean
Dim items() As String
items = texttocheck.ToLower.Split(New Char() {","c, "."c, "?"c, "!"c, "'"c, " "c}, StringSplitOptions.RemoveEmptyEntries)
myregex = New Regex("[?!s.""0-9]")
For Each item As String In items
item = myregex.Replace(item, "")
If listgrosmots.Contains(item) Then
Return True
End If
Next
Return False
End Function
Dim pattern As String = "\bw+\b" 'Remplacer w+ par un mot les \b représentent la position avant et après le mot (voir cours) Dim rx As New System.Text.RegularExpressions.Regex(pattern, RegexOptions.Compiled) 'Creation du Regex avec sa condition (son pattern) MsgBox(rx.IsMatch(TextBox1.Text)) 'affiche True si le mot et sa condition sont détectés, si non affiche False