Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

正则表达式中 \ 也会被吞 #335

Open
shenhuaxin opened this issue Jul 19, 2024 · 3 comments
Open

正则表达式中 \ 也会被吞 #335

shenhuaxin opened this issue Jul 19, 2024 · 3 comments

Comments

@shenhuaxin
Copy link

对于正则表达式的 \d 等符号也会丢失,有什么通用的方法解决转义符号丢失的问题吗

REPLACEREG("xxx4ch", '(\d*)ch', "中间包第$1炉")
public class ReplaceRegOperator extends Operator {

    @Override
    public Object executeInner(Object[] list) throws Exception {
        if (list == null) {
            return "";
        }
        if (list.length < 3) {
            return list[0];
        }
        return ReUtil.replaceAll((CharSequence) list[0], (String) list[1], (String) list[2]);
    }
}
@DQinYuan
Copy link
Collaborator

用两个斜杠试试

@pengpengno
Copy link

pengpengno commented Oct 31, 2024

用两个斜杠试试

#310 查看了这次 commit 中没有 对 \\* 这类 转义处理成 \*,看代码是 直接 去除了\\提到到ql里面,可能 时间比较久 ,不知道现在是否更新了;

但是 在现在 最新版本 3.3.4中使用 转义 或是 正则其中的\\ \ 还是会被去除掉。

@pengpengno
Copy link

#310

 case CHARS:
                            if (curChar == '\\') {
                                state = EscapeState.MAYBE_ESCAPE;
                                continue;
                            }
                            escapedStr.append(curChar);
                            if (curChar == c) {
                                state = EscapeState.END;
                                break forward;
                            }

根据这次 commit , 想到可以 临时使用 \\\ 来处理转义,使用后可行;
但是治标不治本, 相同问题可以采用这个方法临时处理,也望社区在 新的 4.0 版本中可以处理掉此问题😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants