Как заменить & ldquo;: abc, cde \ t & rdquo; to & ldquo; abc | cde & rdquo; используя регулярные выражения в Java?

Использовать «аргументы» модуля из bash-modules

Пример:

#!/bin/bash
. import.sh log arguments

NAME="world"

parse_arguments "-n|--name)NAME;S" -- "$@" || {
  error "Cannot parse command line."
  exit 1
}

info "Hello, $NAME!"

-1
задан Jeffrey Chung 26 March 2019 в 17:30
поделиться

1 ответ

Попробуйте это:

public class T28Regex {
public static void main(String[] args) {
    String[] strings = { "<someother string without *>:abc\t<some other string without \t>",
            "<someother string without *>:abc,cde\t<some other string without \t>",
            "<someother string without *>:abc,efg,cde\t<some other string without \t>",
            "<someother string without *>:abc,cde\t<some other string without \t>" };

    for (String s : strings) {
        System.out.println(s.substring(0, s.indexOf(":")) + "|"
                + s.substring(s.indexOf(":") + 1, s.indexOf("\t", s.indexOf(":"))).replaceAll(",", "|")
                + s.substring(s.indexOf("\t", s.indexOf(":"))));
    }
}
}
0
ответ дан mayamar 26 March 2019 в 17:30
поделиться
Другие вопросы по тегам:

Похожие вопросы: