选择字符串的一部分
我有一个存储在变量中的字符串,假设
$input = 999 success: id:10.123/AVC13231 | ark:/asf4523/2425fsaf
我只想选择字符串“10.123/AVC13231”的一部分,
假设我想实现此目的:
$output = 10.123/XXXXXXXX ;
并且不应选择其他部分 $input,即使是 id: 部分
值 10.123 是常量并且AVC13231 的值动态变化。
我怎样才能实现上述目标?
I have a string stored in variable say
$input = 999 success: id:10.123/AVC13231 | ark:/asf4523/2425fsaf
I want to select only a part of a string "10.123/AVC13231"
say i want to achieve this:
$output = 10.123/XXXXXXXX ;
and no other part $input should be selected even the id: part
The value 10.123 is constant and the value AVC13231 changes dynamically.
How can i achieve the above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是一个解决方案。
Here's a solution.
以及强制正则表达式解决方案:
And the mandatory regex solution:
您还可以使用:
未测试,但逻辑是存在的,只需正确调整算法...
You could also use:
Not tested, but the logic is there, just adapt correctly the algorithm...
试试这个
Try this