> I have a text and I need to find a Word that are not enclosed in
> paranthesis.
Did you try character classes. This'll givu an idea to get started:
[^(]WORD[^)]
~Jason
--
> I have a text and I need to find a Word that are not enclosed in
> paranthesis. Can it be done with a regex? Is someone could help me?
[quoted text clipped - 7 lines]
>
> thanks a lot
I like this method :)
StringBuilder sb = new StringBuilder();
int depth = 0;
foreach (char c in str)
{
if (c == '(') depth++;
else if (c == ')') depth--;
else if (depth == 0) sb.Append(c);
}
string noParentheses = sb.ToString();
--
Chris Fulstow
MCP, MCTS
http://chrisfulstow.blogspot.com/
> I have a text and I need to find a Word that are not enclosed in
> paranthesis. Can it be done with a regex? Is someone could help me?
[quoted text clipped - 7 lines]
>
> thanks a lot
Martin Z - 31 Oct 2006 19:16 GMT
Chris' method is best, since regexes don't deal well with recursive
concepts. After all, you don't want to just consider the case of "am I
in parentheses" - you have to be able to handle that in
((((( foo )))) bar (((( baz )))))
bar is within the outermost set of parens.
> I like this method :)
>
[quoted text clipped - 25 lines]
> >
> > thanks a lot