[英]Jflex Regular expression for string with escaped characters
I am generating lexical analyzer with JFLEX.我正在使用 JFLEX 生成词法分析器。 I need to find all strings which containing escaped characters using regular expressions.我需要使用正则表达式找到所有包含转义字符的字符串。 I'm struggling with this.我正在为此苦苦挣扎。 What could it be?会是什么呢?
I recommend you to read Jflex manual .我建议您阅读Jflex 手册。 I think you can add any escape characters you want to the grammar like this code.我想你可以像这段代码一样在语法中添加任何你想要的转义字符。
EscapeChar = \r | \n | \r\n | \t | \b //add more ...
Regex = ( [:jletterdigit:]* {EscapeChar}+ [:jletterdigit:]* )*
You can also use Unicode compliances either for all things that start with \
but I'm not sure if it's a good way.您也可以对所有以\
开头的内容使用 Unicode 合规性,但我不确定这是否是一个好方法。
EscapeChar = \u005 [:jletter:]
Regex = ( [:jletterdigit:]* {EscapeChar}+ [:jletterdigit:]* )*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.