List Info

Thread: finding a character when not between characters




finding a character when not between characters
user name
2006-02-14 16:41:00
Hello,

I require the ability to find the start and end of a
function.

I am doing this on the basis that all functions have a
opening and
closing bracket ( { } ) with x amount of opening and closing
brackets
between them.

I have factored that comments may contain { } chars and so
strip them
from the input.

However, how would I be able to factor that the  { }
characters may be
contained as a string literal such as var s='}';   ?

I cannot strip this out because it is a part of the function
itself.

Thanks for your help,

Gary

finding a character when not between characters
user name
2006-02-14 21:27:23
Sounds like a compiler issue, where multiple passes are done
to a body
of code before the final object is created...during the
first phase
each object is tokenized and the grammar is checked.

Once that is done the actual work can be done on the tokens,
such as
stripping out the comments, ignoring the quoted text and so
on...also
your code may need to deal with imcomplete code and deal
with it
accordingly.

You may need to take a similar approach....if you can't
find a magic
expression.

Just my opinion...I could be wrong.

finding a character when not between characters
user name
2006-02-16 12:09:37
> I am doing this on the basis that all functions have a
opening and
> closing bracket ( { } ) with x amount of opening and
closing brackets
> between them.
>
> I have factored that comments may contain { } chars and
so strip them
> from the input.
>
> However, how would I be able to factor that the  { }
characters may be
> contained as a string literal such as var s='}';   ?

Can't be done with a single regular expression.  You'll
need 4, one for
{, one for }, one for comments, and one for strings.

See http://www.regular-expressions.info/examplesprogramme
r.html

Kind regards,
Jan Goyvaerts
--
Get your copy of RegexBuddy at http://www.regexbuddy.com/



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )