drpfu51608120170 2017-02-22 02:19
浏览 31
已采纳

正则表达式 - 将组1作为“完全匹配”/组0

Given the following examples, I want to get the email address

Eg. 1: some standard text.   Bugs Bunny bugs@gmail.com 0411111111 more standard text 
Eg. 2: some standard text.   Bugs The Bunny bugs@gmail.com 0411111111 more standard text
Eg. 3: some standard text.   Bugs-Bunny bugs.bunny@gmail.com 0411111111 more standard text
Eg. 4: some standard text.   Bugs bugs.bunny@gmail.com +6141 111 111 more standard text
Eg. 5: some standard text.   Bugs o'Bunny bugs@gmail.com 0411111111 more standard text 

This will do it: (?<=some standard text. )(?:.*?)([^\s]+@[^\s]+) https://regex101.com/r/A29hjE/9

But the email address is in group 1. I need it to be group 0 or the full match because this regex will be created dynamically by some code in which all other regex's produce their findings as the full match.

I don't know enough about groups, but I know I need the first email address after the some standard text. bit and, like I said, it need's to be the full match.

  • 写回答

3条回答 默认 最新

  • dongnigeng1295 2017-02-22 02:26
    关注

    If you change your regex to simply be ([^\s]+@[^\s]+), the full result should be just the email address.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?