Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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 从字符串中提取国家名称的正则表达式_Regex_Regexp Replace - Fatal编程技术网

Regex 从字符串中提取国家名称的正则表达式

Regex 从字符串中提取国家名称的正则表达式,regex,regexp-replace,Regex,Regexp Replace,我有一堆字符串,我想从中提取国家名称 http://api.com/Location_Republic_of_the_Congo_1000 http://api.com/Location_US_994 似乎我需要提取第一个“”和最后一个“”符号之间字符串的Regexp。对于上面的示例,我希望得到以下结果: Republic_of_the_Congo US 我写道:REGEXP_EXTRACT([Country],”(?您可以使用 REGEXP_EXTRACT([Country], '_(.*

我有一堆字符串,我想从中提取国家名称

http://api.com/Location_Republic_of_the_Congo_1000
http://api.com/Location_US_994
似乎我需要提取第一个“”和最后一个“”符号之间字符串的Regexp。对于上面的示例,我希望得到以下结果:

Republic_of_the_Congo
US
我写道:
REGEXP_EXTRACT([Country],”(?您可以使用

REGEXP_EXTRACT([Country], '_(.*)_')

这里,

  • -下划线
  • (.*)
    -捕获组#1:除换行符以外的任何0个或更多字符,尽可能多(由于
    *
    贪婪量词)
  • -下划线

感谢您的回答。您如何提取以下内容?从以下内容:RecordedCase\u亚美尼亚\u 558\u 3\u 20\u 2020\u Cov\u Death,我想分别提取'Cov\u Death'和'Death'。我想提取最后两个'sign@Eren如果我的解决方案解决了你的问题,请考虑接受/接受。关于评论,它是单独的I。问题2:事实上,要获得
Cov\u死亡
使用
([^\u]+.[^\ u]+)$
,要获得
死亡
,使用
([^\u]+)$