Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RegEx Question

Posted on 2006-07-20
1
Medium Priority
?
162 Views
Last Modified: 2010-04-30
I am trying to write a program the recognizes VB lines such as Public Sub.....() Private Function....() etc..

I do NOT want Private|Public Declare statements. Only subs and functions.

The regular expression I am using is:

.Pattern = "[Private|Public Function|Sub].*\)"

That is, of course, picking up the Declare statements. How do I write one that says "Private or Public AND one space AND Function or sub, followed by any number of anything, and ending in a closed parenthesis"?
0
Comment
Question by:DrDamnit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 2000 total points
ID: 17152909
Hi, the following regex should do what your after:

^(Private|Public)\s{1}(Function|Sub).+\)$

Explanation: string must start with either Private or Public followed by one empty space then either Function or Sub and finally one or more of any character then finally finishing with a closing bracket.. I don't know if you want to cater for this situation but a function signature ends with the return type ... e.g.

Public Function ProcessSomething(ByVal Data As String) As Boolean

Your current regex says that the last character should be a closing bracket... if you want to match a full function signature then you could use the following regex:

^(Private|Public)\s{1}(Function|Sub).+(As\s.+|\))$
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question