我写了一个正则表达式,用double-qoutes分割字符串:
Pattern delimeter = Pattern.compile("\"");
如何将其扩展为与单双qoutes一起使用?
我试过了:
Pattern delimeter = Pattern.compile("\"'");
但这是行不通的
有两种方法:
Pattern delimeter = Pattern.compile("[\"']"); //Enclose them in brackets Pattern delimeter = Pattern.compile("\"|'"); //But a "OR" between them.