Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 在typescript中使用正则表达式获取两个字符之间的字符串_Regex_Typescript - Fatal编程技术网

Regex 在typescript中使用正则表达式获取两个字符之间的字符串

Regex 在typescript中使用正则表达式获取两个字符之间的字符串,regex,typescript,Regex,Typescript,我想从下面的代码行中提取字符串 span id=“testing”这是测试span a id=“test”链接a 从上面的代码中,我想使用regex单独提取id 例如:“testing”、“test”您可以使用id=“(\w+)”作为正则表达式。如果您的标识符仅包括: 此正则表达式有效:(?正则表达式可以简单地类似于”(\w+)如果您的标识符仅由“单词字符”(字母、下划线)组成,我只想提取id=”之间的字符串不,我的意思是我想获取id=”之间的字符串仅供参考。最好使用捕获组,因为safari不支

我想从下面的代码行中提取字符串

span id=“testing”这是测试span a id=“test”链接a

从上面的代码中,我想使用regex单独提取id


例如:“testing”、“test”

您可以使用
id=“(\w+)”
作为正则表达式。

如果您的标识符仅包括:


此正则表达式有效:
(?正则表达式可以简单地类似于
”(\w+)
如果您的标识符仅由“单词字符”(字母、下划线)组成,我只想提取id=”之间的字符串不,我的意思是我想获取id=”之间的字符串仅供参考。最好使用捕获组,因为safari不支持lookbehinds。@HaoWu,说得对