我想要 Javascript 正则表达式从 google 表格 URL 中提取电子表格 ID 和工作表 ID。Sheets.google.com 电子表格的网址如下所示:https://docs.google.com/spreadsheets/d/1QOKbrUz7AWUwT-hNfWd1Pxf__QObYCZ1rD2CKMjpnGw/edit#gid=0。
此链接描述了用于提取电子表格 ID 和工作表 ID 的正则表达式。我在 Javascript 中尝试过它们,但它不起作用。这是我尝试过的代码:
var spreadsheetId = new RegExp("/spreadsheets/d/([a-zA-Z0-9-_]+)").exec(resourceUrl);
var sheetId = new RegExp("[#&]gid=([0-9]+)").exec(resourceUrl);Run Code Online (Sandbox Code Playgroud)
我想找出以下字符串模式vim并用其他东西替换它.你能告诉我regex同样的事吗?
1.
11.
20.
21.
99.
Run Code Online (Sandbox Code Playgroud)
基本上是一个/两个数字后跟点.