我有这种模式我试图匹配一个字符串,但它不起作用,我不知道为什么。这就是我所拥有的:
Pattern wDecimal = Pattern.compile("((\\d+)\\.(\\d+))\\'"); // 12.5'
Matcher mwDecimal = wDecimal.matcher(line);
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String line = "";
System.out.println("Please input your Architectural String: ");
boolean flag = false;
while(!flag) {
line = input.nextLine();
System.out.println(wDash.matcher(line).matches());
if(mwDecimal.find()) {
formatwDecimal(line, mwDecimal);
}
else System.out.println("Done");
}
}
我尝试使用.find()和.matches()进行测试,但是当输入为12.5'
时它们都返回false
知道为什么它不起作用吗?谢谢!
如果需要,这里是函数调用的代码:
public static void formatwDecimal(String s1, Matcher m) {
if (m.find()) {
double feet = Double.parseDouble(m.group(1));
int feetPart = Integer.parseInt(m.group(2));
double inchesPart = Double.parseDouble(m.group(3));
double output = feet * 12;
System.out.print(s1 + " | " + "Meaning: " + feetPart + " Feet and " + f.format((inchesPart * 0.1) * 12)
+ " inches. | " + Double.parseDouble(g.format(output)) + " decimal inches.");
}
}
答案 0 :(得分:0)
从输出中可以清楚地看出正则表达式是错误的。 以下reg ex将为您服务
Sink<String, CompletionStage<Done>> jmsSink = JmsProducer
.textSink(
JmsProducerSettings
.create(connectionProvider.get())
.withQueue(queueName)
);
someActor = Source
.queue(Integer.MAX_VALUE, OverflowStrategy.backpressure())
.runWith(jmsSink, materializer); // it doesn't like jmsSink, it wants a graph