douchen7555 2012-03-18 10:00
浏览 54

str_replace和数字

The issue I'm having is I need to replace a few variables in strings with data, for example:

Blah blah S_10 blah S_1 blah blah S_5 blah blah S_15

So the problem is when I iterate through all of the strings, the S_1 replacement undesirably can replace the first 3 characters of S_10 and S_15, so the string will look like

Blah blah APPLE0 blah APPLE blah blah ORANGE blah blah APPLE5

What's the best way to approach this challenge?

  • 写回答

5条回答 默认 最新

  • douchongzhang9267 2012-03-18 10:07
    关注

    Probably not the best solution, but given the information presented. Maybe you can you use the string replace method (str_replace) using an order of S_15, S_10, S_5, followed by S_1. That way you don't get that conflict.

    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)