Extracting Javascript features

6 views
Skip to first unread message

Neha Jain

unread,
Jul 3, 2010, 10:38:06 AM7/3/10
to pho...@googlegroups.com


Hello Gentle Reader,

Using the simple idea of Regular Expressions, I have worked out the way to extract the ratio of the white space

(re.findall("\s",line))

in the JS script to the script length.
Apart from this I was planning, as you know, on finding the %of comments in the JS code. I have written the attached regular expression for stripping the comment from the string considering the fact that:
1. Single line comments in JS either follow // or are within /* */
2. these patterns don't work if are enclosed in " "
3. multi line comments are bounded by /* */

The expression I worked out doesnot function well in case /* or  */ are immediately followed by the string patterns or if there is a different pattern within the construct with special chars or sequence of alphabets and digits.
Then after properly thinking on this idea of ratio of comment strings to file length, I find that it not very useful. So may I drop it for a while? I think it is better to concentrate on extracting the following features:

1. length of argument in the unescape(), eval() function.
2. string passed to the document.write or document.writeln method
3. length of variable names.

Apart from this JS oriented approach, I also came across the use of Meta tag of html for redirection of pages. I will get a proper idea on this and find how we could put it to use.
Awaiting your comments.
--
Sincere Regards,
Neha Jain



--
Smiles
Neha )))))
strex.py
strexp.js
Reply all
Reply to author
Forward
0 new messages