duanping1632 2013-08-10 12:43
浏览 33

从一组sting中删除价格(xx.00),其中xx可以是0到1000s

I want to remove all the price from my text

eg.

"CVC 50/50 Flat Sheet: 250 74 x 110 Plain 1.00 10 10.00"

i want to remove every prices in the text in order to have only the quantity number

"CVC 50/50 Flat Sheet: 250 74 x 110 Plain 10"

i tried

str_replace('(i don't know what to put here).00',' ',$Body)

Please assist with some str_replace pattern or something that will fix this problem.

Many thanks!!

P.s. The prices are vary from 0.00 to xxxxx.00

  • 写回答

1条回答 默认 最新

  • dongxie2756 2013-08-10 12:55
    关注

    You can just use preg_replace instead which makes the matching fairly straight forward;

    $a = "CVC 50/50 Flat Sheet: 250 74 x 110 Plain 1.00 10 10.00";
    
    echo preg_replace('/\s\d+\.00/', '', $a);    // whitespace+digits+.00 -> ''
    
    >> CVC 50/50 Flat Sheet: 250 74 x 110 Plain 10
    
    评论

报告相同问题?

悬赏问题

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