Tag: str replace

循环并replace文件名中的反斜杠(string)

我试图replace我从数据库中查询的文件名中包含的\ 。 我的脚本通过一个包含项目代码的CSV循环。 对于每个项目代码,查询数据库并检索项目名称。 但是,项目名称包含\正在尝试replace。 $startRow = 2 $col = 3 $excel = New-Object -COM Excel.Application $wb = $excel.Workbooks.Open("\myprojectfolder\projectcodes.csv") $excel.Visible = $false for ($i = 1; $i -le $wb.Sheets.Count; $i++){ $sh = $wb.Sheets.Item($i) $endRow = $sh.UsedRange.Rows.Count $rangeAddress = $sh.Cells.Item($startRow,$col).Address() + ":" + $sh.Cells.Item($endRow,$col).Address() $sh.Range($rangeAddress).Value2 | foreach { #GET PROJECT NAME TO APPEND TO FOLDER NAME […]

如何在php中使用str_replace()函数replaceexcel文件占位符?

下面的PHP代码完全适用于word文档(特定的.docx ),但对于excel( .xlsx ),它不会改变占位符。 据我所知,这个代码将word文件转换成document.xml文件,并将zip文件的word文件夹内的文件转换成{{placeholder}}并将其更改为我们想要的文本。 if(isset($_POST["e_submit"])) { $name=(string) $_POST["e_name"]; $email=(string) $_POST["e_email"]; $source='TemplateSimpleText.docx'; $temp='template'.'.docx'; copy($source,$temp); $zip = new ZipArchive; $fileXml='word/document.xml'; if($zip->open($temp) === TRUE) { $old=$zip->getFromName($fileXml); $new=str_replace('{{Name}}',$name,$old); $new=str_replace('{{Email}}',$email,$new); $zip->deleteName($fileXml); $zip->addFromString($fileXml,$new); $zip->close(); if (ob_get_level()) { ob_end_clean(); } header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($temp)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . […]

replacestringvariables(VBA)中的多个字符

我怎样才能replacestringvariables中的多个事物? 在这里我的示例函数在VB中: Private Function ExampleFunc(ByVal unitNr$) As String If InStr(unitNr, "OE") > 0 Then unitNr = Replace(unitNr, "OE", "") unitNr = Replace(unitNr, ";", "") End If … End Function 有更好的解决scheme吗?