[ASP] Regular Expression : Replace Match

Pagina: 1
Acties:

  • Mischa_NL
  • Registratie: Mei 2004
  • Laatst online: 01-02-2023
Ik ben nog steeds bezig met mijn if then else statement (zie een paar topics hieronder) .

Maar nu loop ik alweer tegen een probleem aan waar ik op google niks over kan vinden...

Ik wil alle matches replacen door niks als test.

ik heb dus dit
Visual Basic:
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
   Set rx = emNewRegExp("if \((.*?)==(.*?)\){(.*?)}", True, True)
   Set Matches = rx.Execute(str)
   
   For Each Match in Matches
     condition1 = Match.SubMatches(0)
     condition2 = Match.SubMatches(1)
     strmatched = Match.SubMatches(2)
     
     if not left(condition1,1) = """" AND not right(condition1,1) = """" then
       condition1 = Eval(condition1)
     end if
     
     if not left(condition2,1) = """" AND not right(condition2,1) = """" then
       condition2 = Eval(condition2)
     end if
 
       str = rx.Replace(Match.Value, "")
   Next 

Function emNewRegExp(spattern, bglobal, bignorecase)
  Dim rx
  Set rx = New RegExp
  rx.Pattern = spattern
  rx.Global = bglobal
  rx.IgnoreCase = bignorecase
  Set emNewRegExp = rx
  Set rx = Nothing
End Function


Nu zit het hem in dat laatste zinnetje in de for loop:
str = rx.Replace(Match.Value, "")

Hij replaced volgens mij niet...

Ook dit werkt niet:
str = Replace(str,Match.Value, "")

Waarom is me een raadsel...
En er is een match dat heb ik gekeken!

Wat kan er nu weer aan de hand zijn? :'(

EDIT/ het lag ergens anders aan. Sorry!

[ Voor 8% gewijzigd door Mischa_NL op 12-03-2005 21:52 ]