Regex 有效正则表达式
好的,我有这根绳子Regex 有效正则表达式,regex,Regex,好的,我有这根绳子 String line = "6!.242.88.10 - - [07/Mar/2004:16:05:49 -0800] \"GET /twiki/bin/edit/Main/Double_bounce_sender? topicparent=Main.ConfigurationVariables HTTP/1.1\" 401 12846"; 我还有一个java正则表达式 Pattern c = Pattern.compile("(\\s+\\/+)(?<
String line = "6!.242.88.10 - - [07/Mar/2004:16:05:49 -0800] \"GET
/twiki/bin/edit/Main/Double_bounce_sender?
topicparent=Main.ConfigurationVariables HTTP/1.1\" 401 12846";
我还有一个java正则表达式
Pattern c = Pattern.compile("(\\s+\\/+)(?<=\\/).*(?=)");
Pattern c=Pattern.compile(“(\\s++\\\/+)(?如果您想要一行,可以尝试使用String.replaceAll
:
String match = line.replaceAll(".*\\s+(/[^?\\s]*)(?:\\?|\\s).*", "$1");
如果需要一行程序,可以尝试使用String.replaceAll
:
String match = line.replaceAll(".*\\s+(/[^?\\s]*)(?:\\?|\\s).*", "$1");
我不能直接把GET放进去,因为它应该是数学的,可能有POST这个词,或者其他任何东西。我只是想让它匹配这个/twiki/bin/edit/Main/Double\u bounce\u sender?或者这个/twiki/bin/edit/Main/Double\u bounce\u senderI再次更新了我的正则表达式。底线是,如果你想t编写一个健壮的正则表达式。但是我需要这个/twiki/bin/edit/Main/Double\u bounce\u发送器(空格或?可以跟在后面)我不能直接把GET放进去,因为它应该是数学的,可能有POST这个词,或者其他任何东西。我只是想让它匹配这个/twiki/bin/edit/Main/Double\u bounce\u sender?或者这个/twiki/bin/edit/Main/Double\u bounce\u senderI再次更新了我的正则表达式。底线是,如果你想t编写一个健壮的正则表达式。但是我需要这个/twiki/bin/edit/Main/Double\u bounce\u发送器(空格或?可以跟在后面)