我有一个描述,其中包含我想要删除的两段文本和要格式化的文本。该字符串可以更改并且其中包含
空格和空格(这是坏数据)。
我需要删除产品名称和末尾的一段文本(两者都可以根据“产品”更改)。我将产品名称存储为一个变量,如下所示:
$prName = "Test CPL560 Home Office Corner Workstation";
需要删除的末尾文本如下:
free delivery5-7 working days assembly required?Yes guarantee2 years dimensions(mm) Width: 1600-2340 Depth: 700-1350 Height: 760
删除产品名称应该相当简单,但最后一段文字让我很困惑,因为宽度、深度等都可能因产品而异。有什么建议么?
完整字符串:
Test CPL560 Home Office Corner WorkstationExecutive, designer style corner workstation. The smart-looking, functional CPL560 with complementing side storage unit featuring high gloss black drawer fronts, provides the perfect solution for the modern, spacious home office. Quality 32mm desktop measuring 1600x700mm, finished with 2mm ABS edge protection providing a comfortable, durable finish. The desktop rear wall features cable guide and rear cable housing. The side return storage unit of the Test CPL560 corner computer desk rotates through 360 degrees to allow the side return to be located and fixed on either the right or left hand side of the desk top, whichever best suits your working position and home office layout. The side return unit comprises 3 push-to-open storage drawers with high gloss drawer fronts, a CPU storage compartment with rear cable management and 2 further storage compartments with one height adjustable shelf. CPL560 Corner Workstation is available in White/High Gloss BlackOptional installation/assembly available for this product free delivery5-7 working days assembly required?Yes guarantee2 years dimensions(mm) Width: 1600-2340 Depth: 700-1350 Height: 760
我想要的是:
测试 CPL560 家庭办公室角落工作站行政,设计师风格的角落工作站。外观时尚、功能齐全的 CPL560 带有互补的侧储物单元,具有高光黑色抽屉前面板,为现代、宽敞的家庭办公室提供了完美的解决方案。优质 32 毫米桌面,尺寸为 1600x700 毫米,采用 2 毫米 ABS 边缘保护,提供舒适、耐用的饰面。桌面后壁具有电缆导向器和后电缆外壳。
Test CPL560 转角电脑桌的侧边返回存储单元可 360 度旋转,以允许侧边返回定位并固定在桌面的右侧或左侧,以最适合您的工作位置和家庭办公室布局为准。侧面返回单元包括 3 个带高光泽抽屉正面的推开式储物抽屉、一个带后部电缆管理的 CPU 储物箱和 2 个带一个高度可调节搁板的其他储物箱。CPL560 转角工作站有白色/高光黑色可供此产品可选安装/组装
我不关心分段发生在哪里,只是为了让它半可读。这可以通过 preg_replace 或正则表达式实现吗?