简体   繁体   English

如何使用Java从.asp文件中删除特定字符串?

[英]How to remove particular string from .asp file, using Java?

I'm currently writing something which is validating our vbscript files. 我目前正在写一些正在验证我们的vbscript文件的文件。 Right at the start I wish to remove all lines of code which are comments. 从一开始,我希望删除所有注释行。 I was expecting to be able to use the "'" (comment symbol in vbscript) and '\\n'. 我期望能够使用“'”(vbscript中的注释符号)和“ \\ n”。 However, when I write the content of the file to screen, the new lines are not formatting. 但是,当我将文件内容写入屏幕时,新行未格式化。 Does this mean there are actually no new lines in the original vbscript file and if not, how could I remove comments? 这是否意味着原始vbscript文件中实际上没有新行,如果没有,我如何删除注释?

first read whole file in string example 首先在字符串示例中读取整个文件

then use regex or simply substring for removing extra syntax 然后使用正则表达式或仅使用子字符串来删除额外的语法

How are you parsing the file? 您如何解析文件? Are you also taking the '\\r' into consideration when removing the comments? 删除注释时,是否还要考虑“ \\ r”? Or maybe you are accidentally removing all newline characters. 也许您不小心删除了所有换行符。

I would create some state flags to tell the parser when I was in a comment or not. 我将创建一些状态标志来告诉解析器何时不在评论中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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