正则表达式 - 如果存在,则在字符之间提取字符串

发布于 2025-02-07 22:27:55 字数 266 浏览 1 评论 0原文

如果存在(结肠字符),我将需要使用正则绳索在字符之间提取字符串。

示例:

  • SX: 22AA 001 267
  • 2294 0bb 267 :09
  • 2294 0cc 267

在所有情况下,我都希望结果。

2294 001 267

谢谢大家。

I would need to use RegEx to extract a string between characters if they exist (The colon character).

Examples:

  • SX: 22AA 001 267
  • 2294 0BB 267: 09
  • 2294 0CC 267

In all cases, I want the result.

2294 001 267

Thank you all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘦怹 2025-02-14 22:27:55

您可以使用 this regex将它们匹配

(?:^|:)\s?([A-Z\d]+(?: [A-Z\d]+)+)(?:$|:)

not ,没有提及您使用的是什么语言,我决定不使用Lookarounds。因此,您必须从比赛中获得第一组。

You can use this regex to match them all

(?:^|:)\s?([A-Z\d]+(?: [A-Z\d]+)+)(?:$|:)

NOTE: As you did not mention what language you're using I decided to not use lookarounds. So you have to get the first group from the match.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文