Help on Regular Expression

  • Thread starter Thread starter Hayato Iriumi
  • Start date Start date
H

Hayato Iriumi

Hi,
I didn't know which newsgroup to post, so I'm posting here hoping to get
a help on Regular Expression.
Here is what I want to do.

I want to find Matches using Regex for the following cases. String look like
the following.


MyObject.ExecuteWhatever(parama, paramB, paramC...)

Or

MyObject.ExecuteWhatever(Parama, _
ParamB, _
ParamC, _
......
ParamR)

So I want to get the string from .Execute... to the end of parenthesis. I
can't assume how many parameters I have because it is param array. I tried
to come up with pattern for this, but couldn't. Can someone please give me
a hand on this?
 
Yes, I'm aware of that site. At this point, getting onto a site doesn't
really help me...
 
Hayato said:
I want to find Matches using Regex for the following cases. String look like
the following.

MyObject.ExecuteWhatever(parama, paramB, paramC...)

Or

MyObject.ExecuteWhatever(Parama, _
ParamB, _
ParamC, _
......
ParamR)

So I want to get the string from .Execute... to the end of parenthesis. I
can't assume how many parameters I have because it is param array.

#[IgnorePatternWhitespace]
\w+ \s* \. \s* # instance, optional white space, dot, optional
white space,
(\w+ \s* # begin capture: method name, optional
whitespace
\( # a literal (

(?: # non-capture group
(?<Stack> \( ) # on nested (, push empty capture
| (?<-Stack> \) ) # on nested ), pop empty capture
| [^()] # anything except ( or )
)* # any number of chars between parens

(?(Stack) # if stack not empty:
^ # then, match beginning of string (ie, fail)
| \) ) # else, match literal )
) # end capture

# supports parenthesized expressions within param list
 
Back
Top