正则表达式从位置 13 到行尾匹配

发布于 12-21 19:59 字数 209 浏览 3 评论 0原文

示例字符串:

DFDBDFDFDF21R123
DFDBDFDFDF21DFD

我需要一个正则表达式,运行时与以下内容匹配:

R123
DFD

(无 EOL 字符)

谢谢,我希望有一个我的大脑没有想到的简单解决方案。

Example strings:

DFDBDFDFDF21R123
DFDBDFDFDF21DFD

I need a regex that when run matches ths following:

R123
DFD

(no EOL chars)

Thanks, I hope there is a simple solution that my brain isn't conjuring.

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

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

发布评论

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

评论(3

悍妇囚夫2024-12-28 19:59:53
/^.{12}(.*)$/

第一部分将查找前 12 个字符并将其丢弃,第二部分将对其余字符进行分组。

编辑:正如其他人指出的那样,您确实应该在您使用的任何语言中使用子字符串。正则表达式太过分了。

/^.{12}(.*)$/

The first part will look for the first 12 characters and throw them out, and the second part will group the rest.

Edit: as others have pointed out, you really should just use substring in whatever language you're using. Regex is overkill.

大姐,你呐2024-12-28 19:59:53
/.{12}(.*)/

匹配前 12 个字符,然后匹配其余字符。

但我同意@chance: substr 会更好。

/.{12}(.*)/

Match the first 12 chars, then match the rest.

But I agree with @chance: substr would be better.

甜是你2024-12-28 19:59:53

我建议改用您语言中的子字符串函数。

如果您确实想要一个正则表达式解决方案,尽管它比您真正需要的速度慢一百倍且复杂,请尝试如下操作:

/.{12}(.*)/

您想要的结果位于第一个捕获组中。

I would suggest using a substring function in your language instead.

If you REALLY want a regex solution, in spite of it being about a hundred times slower and more complex than you really need, try something like this:

/.{12}(.*)/

Your desired result is then in the first capture group.

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