[ASP & RegExp] Variables

Pagina: 1
Acties:

  • didio
  • Registratie: Maart 2001
  • Laatst online: 01-04 09:19

didio

didio.nl

Topicstarter
Ik heb een stuk html code (html code kan van alles zijn en staat nooit vast), zeg eventjes:
code:
1
<table><tr><td>14 april 2003</td></tr></table>


Nou wil ik zometeen een array hebben met 3 waarden, te weten: 14, april, 2003

De beste manier lijkt mij met Regular Expressions, deze code heb ik tot nu:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Dim objRegExp, strMatch, strContents
Set objRegExp = New RegExp

strMatch = "<td>(.*?) (.*?) (.*?)</td>"
strContents = "<table><tr><td>14 april 2003</td></tr></table>"

objRegExp.Pattern = strMatch
objRegExp.IgnoreCase = True
objRegExp.Global = True

Dim objMatches, objMatch
Set objMatches = objRegExp.Execute(strContents)
For Each objMatch in objMatches
  Response.Write objMatch.Value & "<br>"
Next
Set objMatches = Nothing
Set objRegExp = Nothing


Ik krijg hier als resultaat:
code:
1
<td>14 april 2003</td>


Terwijl ik dus eigenlijk wil:
code:
1
2
3
14
april
2003


Is dit mogenlijk, zoja, kan iemand mij op weg helpen?

weinig tot niks..


  • Shir
  • Registratie: November 2000
  • Laatst online: 25-11-2025
Als je Non-greedy repetition (.*?) wil gebruiken, dan moet je script versie minstens 5.5 zijn. Zie http://www.4guysfromrolla.com/webtech/122199-1.shtml

  • _Thanatos_
  • Registratie: Januari 2001
  • Laatst online: 22-06 10:32

_Thanatos_

Ja, en kaal

Je moet werken met de SubMatches collection binnen een match... er staan op MSDN prachtige voorbeeldjes van.

/edit
Shir, als Non-greedy niet zou werken, zou (.*?) helemaal tot het einde van de string matchen...

[ Voor 35% gewijzigd door _Thanatos_ op 14-04-2003 16:52 ]

日本!🎌


  • Shir
  • Registratie: November 2000
  • Laatst online: 25-11-2025
_Thanatos_ schreef op 14 April 2003 @ 16:50:
Je moet werken met de SubMatches collection binnen een match... er staan op MSDN prachtige voorbeeldjes van.

/edit
Shir, als Non-greedy niet zou werken, zou (.*?) helemaal tot het einde van de string matchen...
Je hebt gelijk 8)7
ASP:
1
2
3
4
5
6
7
Set objMatches = objRegExp.Execute(strContents)

set objMatch = objMatches(0)

for each item in objMatch.SubMatches 
      response.write( item & "<br>" )
next

  • didio
  • Registratie: Maart 2001
  • Laatst online: 01-04 09:19

didio

didio.nl

Topicstarter
Toppie jongens, ik heb het en werkt perfect, thanks

weinig tot niks..