Need perl regular expression

Hi,

I am looking for a Perl regular expression to match the below pattern of a java script file.

            var so = object.device.load('camera','value');

I want to grep out such lines present in the *.js files. The conditions are:

a) the line may start with blank space(s)
b) always the string remains same as "var so = object.device.load(....);" but differs in the arguments & quotes (may be single or double) inside parantheses
c) should not be included if it is commented using /* */ (or) // where as it may be multi-line comments (i.e)

  
     /*
         .....
         var so = ..... 
    */

Somehow, I managed to get the below regexp by google search

^(\\s*)var *.*object[ .]*device.*[ )] *;$

but not working with the comments part

Any help would be highly appreciated!!

If you are ok with the regex, and comment is the only issue.

Then strip of the comments using some technique, you know. cloc is one of the option i can suggest, but i am not sure about the perfectness of it.

Hi,

try this,

sed '/\/\//d' inputfile | sed  '/\/\*/,/\*\//d' | grep "^\s*var *.*object[ .]*device.*[ )] *;"

Hi ,

I really doubt if we have multi line comments in perl ( /* and */)

$line=q#var so = object.device.load('camera','value');#

This should do the prick for you