[英]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?我如何使用 Java 做到这一点?
You can achieve this by writing your own Parser for javascript and exporting the result into a new file with a filewriter.您可以通过为 javascript 编写自己的解析器并使用文件编写器将结果导出到新文件中来实现这一点。 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.此外,如果您的脚本在 HTML 中,您可以使用JSOUP和手动解析。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.