我需要帮助查找 java regex 模式以从 URI 获取一个查询信息。例如这里的URI是
"GET /6.2/calculateroute.xml?routeattributes=sm,wp,lg,bb&legattributes=mn&maneuverattributes=ac,po,tt,le,-rn,-sp,-di,no,nu,nr,sh&instructionFormat=html&language=en_US&mode=fastest;car;traffic:default&waypoint0=37.79548,-122.392025&waypoint1=36.0957717,-115.1745167&resolution=786&app_id=D4KnHBzGYyJtbM8lVfYX&token=TRKB7vnBguWLam5rdWshTA HTTP/1.1"
我需要从中提取 4 个值,我设法做到了:
GET
/6.2/calculateroute.xml
routeattributes=sm,wp,lg,bb&legattributes=mn&maneuverattributes=ac,po,tt,le,-rn,-sp,-di,no,nu,nr,sh&instructionFormat=html&language=en_US&mode=fastest;car;traffic:default&waypoint0=37.79548,-122.392025&waypoint1=36.0957717,-115.1745167&resolution=786&app_id=D4KnHBzGYyJtbM8lVfYX&token=TRKB7vnBguWLam5rdWshTA
HTTP/1.1
现在的问题是如何从查询字符串中为 app_id 值编写正则表达式。注意 app_id 不会出现在所有模式中,所以它应该是通用的,如果 app_id 缺失,正则表达式不应该失败。请帮忙...