[ASP] Regular Exp: woord matchen

Pagina: 1
Acties:

  • Mischa_NL
  • Registratie: Mei 2004
  • Laatst online: 01-02-2023
Ik ben bezig met een highlighter voor c# (en andere talen) maar nu loop ik tegen een probleempje op! Graag geen antwoorden: 'dit kan nooit helemaal goed werken met Reg Expressions' want ik maak niet alleen gebruik van regular expressions ;).

Ik wil alle woorden met deze syntax matchen: '[woord]()' .

Dus bijvoorbeeld : 'Main()' of 'MyFunction()' enzovoort.

Nu dat ik dat dit de oplossing was:

Visual Basic:
1
2
RegExpr.Pattern = "(([a-z_A-Z].*?)\((.*?)\))"
Mystring = RegExpr.Replace(Mystring, "<font color=""#000000""><strong>$1</strong></font>") 


Maar zo matcht hij dus niet :( .

Weet iemand hoe ik het wel kan laten werken?

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 15-04 22:07

NMe

Quia Ego Sic Dico.

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.


  • Mischa_NL
  • Registratie: Mei 2004
  • Laatst online: 01-02-2023
Bedankt ik ben er uit gekomen!

De oplossing was uiteindelijk dit:

Visual Basic:
1
2
RegExpr.Pattern = "(\b[a-z_A-Z]*\b\(\))"
strReplace = RegExpr.Replace(strReplace, "<font color=""#000000""><b>$1</b></font>")


Terwijl ik dit al geprobeerd had:
Visual Basic:
1
2
RegExpr.Pattern = "(\b[a-z_A-Z]*\(\)\b)"
strReplace = RegExpr.Replace(strReplace, "<font color=""#000000""><b>$1</b></font>")


De \(\) moet dus buiten de Word Boundarie staan!

Bedankt voor de hulp maar weer! _/-\o_