parsing VB code with a regex
- From: "Mark" <emby@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 5 Jun 2006 22:14:41 -0400
I must create a routine that finds tokens in small, arbitrary VB code
snippets. For example, it might have to find all occurrences of
{Formula}
I was thinking that using regular expressions might be a neat way to solve
this, but I am new to them. Can anyone give me a hint here?
The catch is, it must only find tokens that are not quoted and not
commented; examples follow
(1) should find {Area} (both occurrences) and {Height} in this string
If {Area} > 100 Then Return {Area} Else Return {Height}
(2) should find {Area}, but not {AreaString} in this string
If {Area} = "{AreaString}" 100 Then Return "Found it!"
(3) should find {Height}, but not {Area} in this multi-line string
'the {Area} token is not used here
If {Height} > 1000 Then
Return "Tall"
Else
Return "Short"
End If
I've searched many web sites and libraries, but they all seem to be
interested in finding quoted strings, not avoiding them. I'd appreciate any
help.
Emby
.
- Follow-Ups:
- Re: parsing VB code with a regex
- From: Kevin Spencer
- Re: parsing VB code with a regex
- From: Jon Shemitz
- Re: parsing VB code with a regex
- Prev by Date: How to change data in grid after you change the SQL select for the data adapter
- Next by Date: RE: checkboxes and checkboxelist
- Previous by thread: How to change data in grid after you change the SQL select for the data adapter
- Next by thread: Re: parsing VB code with a regex
- Index(es):
Relevant Pages
|