Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2116 connectés 

  FORUM HardWare.fr
  Programmation
  Algo

  RegExp

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

RegExp

n°683680
art_dupond
je suis neuneu... oui oui !!
Posté le 25-03-2004 à 12:21:21  profilanswer
 

youp,
 
 
j'ai une ligne :


<div class="appliesto" id="appliesto" name="appliesto"><h3>The information in this article applies to:</h3><ul><li>Microsoft Outlook Express 6.0 SP1, when used with:<ul>  the operating system: Microsoft Windows XP SP1</ul><ul>  the operating system: Microsoft Windows Millennium Edition</ul><ul>  the operating system: Microsoft Windows 2000 SP2</ul><ul>  the operating system: Microsoft Windows 98 Second Edition</ul><ul>  the operating system: Microsoft Windows NT 4.0 SP6a</ul></li><li>Microsoft Outlook Express 6.0, when used with:<ul>  the operating system: Microsoft Windows XP</ul></li><li>Microsoft Outlook Express 5.5 for Windows 98 Second Edition</li><li>Microsoft Outlook Express 5.5 for Windows Millennium Edition</li><li>Microsoft Outlook Express 5.5 for Windows 2000</li><li>Microsoft Outlook Express 5.5 for Windows NT 4.0</li></ul></div>


 
dont je voudrais extraire les paires <li></li>
 
le problème, c'est qu'il me donne chaque fois toute la ligne comprise entre le premier <li> et le dernier </li>
 
 
mon code en VB:

Code :
  1. Private Sub Command1_Click()
  2. Dim i As Integer
  3. Dim moiur As String
  4.     moiur = "<div class=""appliesto"" id=""appliesto"" name=""appliesto""><h3>The information in this article applies to:</h3><ul><li>Microsoft Outlook Express 6.0 SP1, when used with:<ul>  the operating system: Microsoft Windows XP SP1</ul><ul>  the operating system: Microsoft Windows Millennium Edition</ul><ul>  the operating system: Microsoft Windows 2000 SP2</ul><ul>  the operating system: Microsoft Windows 98 Second Edition</ul><ul>  the operating system: Microsoft Windows NT 4.0 SP6a</ul></li><li>Microsoft Outlook Express 6.0, when used with:<ul>  the operating system: Microsoft Windows XP</ul></li><li>Microsoft Outlook Express 5.5 for Windows 98 Second Edition</li><li>Microsoft Outlook Express 5.5 for Windows Millennium Edition</li><li>Microsoft Outlook Express 5.5 for Windows 2000</li><li>Microsoft Outlook Express 5.5 for Windows NT 4.0</li></ul></div>"
  5.     Set ObjRegex = New RegExp
  6.     ObjRegex.Global = True
  7.     ObjRegex.IgnoreCase = True
  8.     ObjRegex.Pattern = "(<li>.*</li> )"
  9.     Set ColMatches = ObjRegex.Execute(moiur)
  10.     If ColMatches.Count > 0 Then
  11.         For i = 0 To ColMatches.Count - 1
  12.             DoEvents
  13.             txtResultat.Text = txtResultat.Text & vbCrLf & ColMatches(i).Value
  14.         Next
  15.     End If
  16. End Sub


 
 
je me dis que ca doit être le pattern qui est pas bon, mais je ne sais pas comment arranger ca :(
 
 
une idée ?  
 
 
merci


---------------
oui oui
mood
Publicité
Posté le 25-03-2004 à 12:21:21  profilanswer
 

n°683700
Tentacle
Posté le 25-03-2004 à 12:40:57  profilanswer
 

peut-être (<li>.*?</li> )  

n°683701
art_dupond
je suis neuneu... oui oui !!
Posté le 25-03-2004 à 12:42:55  profilanswer
 

oui ca marche, merci :)
 
 
tu sais m'expliquer pourquoi ?


---------------
oui oui
n°683704
art_dupond
je suis neuneu... oui oui !!
Posté le 25-03-2004 à 12:45:20  profilanswer
 

en fait dans la page, j'ai y a pleins de <div> et j'emploie une regexp pour isoler la div que je veux pour ensuite extraire les <li></li>
 
y aurait pas moyen de tout faire en une fois : trouver la bonne <div> puis extraire les <li><li> ?


---------------
oui oui
n°683706
Tentacle
Posté le 25-03-2004 à 12:46:20  profilanswer
 

le signe * est gourmand, c'est à dire qu'il va essayer de prendre le maximum de caractères. Mettre un ? après permet de le mettre au régime et cela va donc récupérer le minimum de caractères. (? tout seul a un sens différent sinon)

n°683713
art_dupond
je suis neuneu... oui oui !!
Posté le 25-03-2004 à 12:54:12  profilanswer
 

yop merci :)


---------------
oui oui
n°683714
Tentacle
Posté le 25-03-2004 à 12:54:22  profilanswer
 

Pour ton autre question, je vois pas :/


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Algo

  RegExp

 

Sujets relatifs
[Regexp] Supprimer tous les espaces,\t,\n\r en dehors des balisesEncore du Regexp
[PHP] petit pb avec une regexpUne quote dans une quote [regexp]
[JS] urgent :'( problemes regexp !- Aide pour script regexp -
Regexp: Savez pourquoi?Programme pour tester des regexp sur du texte?
[regexp] serialize unserialize transparent entre php et js :)Problème avec les regexp...
Plus de sujets relatifs à : RegExp


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR