简体   繁体   中英

I want the function name and body of that function from a javascript to get parsed out into a separate file. How do I do that using Java?

I have the following sample code:

 <Script> var lastEntdFld ; var fldobj ; var Args ; var errormsg ; function InitJSvar(){ try { //Some texts }catch(e){} } </script>

After parsing I want the following code:

function InitJSvar(){
   try {
        //Some texts
       }catch(e){}
    }

How can I do that using Java?

You can achieve this by writing your own Parser for javascript and exporting the result into a new file with a filewriter. I think this would be the easiest way to do it.

Also if your script is in a HTML You can use JSOUP and manual parsing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM