字符串中数字和汉字之前打空格

    public static void main(String[] args) {
        String regex = "(?<=[\\u4e00-\\u9fa5A-Za-z])(?=[0-9])|(?<=[0-9])(?=[\\u4e00-\\u9fa5A-Za-z])";

        String input = "大床1.8米";

        String result = input.replaceAll( regex, " " );

        System.out.println(result);
    }

大床 1.8 米

 

posted @ 2021-10-29 14:57  小啊菜鸡  阅读(44)  评论(0编辑  收藏  举报