I have this js
我有这个js
var race = {
"id": Number( matches[ i ].match( /gt5bspec\.selectEvent\("/(\d+/\d+)"\)/ )[ 1 ] ),
"laps": Number( matches[ i ].match( /<dd class="lap">.+?(\d+)/ )[ 1 ] ),
"maxEntrants": Number( matches[ i ].match( /entry_max.+?\/>(\d+)<\/dd>/ )[ 1 ] ),
"time": Number( matches[ i ].match( /common\/time\/(\d+)\.png/ )[ 1 ] ),
};
its failing SyntaxError: illegal character on the "id" line I am guessing due to the quotes in the expression.
它失败的SyntaxError:由于表达式中的引号,我猜测“id”行上的非法字符。
here is an example string that is used for the search
这是一个用于搜索的示例字符串
<dl class="remote_event_list"> <dd class="course_logo"><img src="/common/images/gt5/remote_race/common/courselogo/ed2539fe892d2c52c42a440354e8e3d5.png" width="84"></dd> <dd class="race_info_minute"><img src="/common/images/gt5/remote_race/common/time/20.png" width="80" height="54" alt=""></dd> <dd class="entry_max"><img src="/common/images/gt5/remote_race/entry/icon_driver.png" width="20" />16</dd> <dd class="lap"><span>Vuelta(s):</span> 12 (en torno a 20 minutos)</dd> <dd class="car_image"> <img src="/common/images/gt5/car/thumbnail/0a712318b3b8acc70daeb1ff71d40140.png" width="178" /> </dd> <dd class="link"><a href="javascript:void(0);" onclick='gt5bspec.selectEvent("/116/1035200")' title="Abt Audi TT-R Touring Car '02 / Circuito de Madrid"> </a></dd></dl>
I am trying to match the group 1 value of /116/1035200
我正在尝试匹配/ 116/1035200的组1值
Thanks
谢谢
1 个解决方案
#1
3
//-----------------------v
/gt5bspec\.selectEvent\("/(\d+/\d+)"\)/
I've marked the unescaped slash. If you want literal slash here, use \/
.
我标记了未转义的斜线。如果你想在这里使用字面斜杠,请使用\ /。
#1
3
//-----------------------v
/gt5bspec\.selectEvent\("/(\d+/\d+)"\)/
I've marked the unescaped slash. If you want literal slash here, use \/
.
我标记了未转义的斜线。如果你想在这里使用字面斜杠,请使用\ /。