替换许多 .php 文件中的字符串

发布于 2024-08-23 01:58:47 字数 143 浏览 2 评论 0原文

我已经下载了一个我创建的网站并且 想要找到域名并将其替换为新域名,而无需打开每个文件。

我使用 EditPlus

有没有任何编辑器可以执行此操作,或者您知道如何在 Windows 或 editplus 中执行此操作吗?

谢谢

i have downloaded a website i have created and
want to find the domain name and replace it with a new one without having to open each file.

I use EditPlus

Is there any editor that can do this or do you know how to do this in windows or editplus?

thx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

︶ ̄淡然 2024-08-30 01:58:47

我建议 Notepad++。它可以搜索和替换一个文件、所有打开的文件或目录中的所有文件。

I'd suggest Notepad++. It has search and replace across one file, all open files, or all files in a directory.

韬韬不绝 2024-08-30 01:58:47

您可以在 powershell 中执行此操作。

$textToRemove = New-Object System.Text.RegularExpressions.Regex "SOMEREGEX", SingleLine

Get-Item "*.php" | ForEach-Object {
    $backupfile = [System.IO.File]::Copy($_.FullName,"NEWPATH")
    $text = [System.IO.File]::ReadAllText($_.FullName)
    $text = $textToRemove.Replace($text, "REPLACEWITHTHIS")
    $newFile = [System.IO.File]::OpenWrite($_.FullName)
    $newFile.Write($text);
    $newFile.Close()
}

以上是未经测试的代码。 Powershell 是自动化此类任务的好帮手。

You can do this in powershell.

$textToRemove = New-Object System.Text.RegularExpressions.Regex "SOMEREGEX", SingleLine

Get-Item "*.php" | ForEach-Object {
    $backupfile = [System.IO.File]::Copy($_.FullName,"NEWPATH")
    $text = [System.IO.File]::ReadAllText($_.FullName)
    $text = $textToRemove.Replace($text, "REPLACEWITHTHIS")
    $newFile = [System.IO.File]::OpenWrite($_.FullName)
    $newFile.Write($text);
    $newFile.Close()
}

The above is untested code. Powershell is your friend for automating tasks like this.

ゃ人海孤独症 2024-08-30 01:58:47

最坏的情况是,您可以使用 Dreamweaver 之类的试用版。

也就是说,我相信 Notepad++ 能够做到这一点。

Worst case scenario, you could go for a trial version of something like Dreamweaver.

That said, I believe that Notepad++ is capable of this.

快乐很简单 2024-08-30 01:58:47

我以为 EditPlus 有一个“继续下一个文件”按钮。

所以打开所有文件
按 Ctrl+F
查找:旧域
替换:newdomain

“全部替换”按钮和“继续下一个文件”按钮。

I thought EditPlus has a "continue to the next file" button.

So Open all files
press ctrl+F
find: olddomain
replace: newdomain

"Replace all"button and "continue to the next file" button.

舞袖。长 2024-08-30 01:58:47

您还可以使用 Eclipse 或 Aptana 来执行此操作

You can also use Eclipse or Aptana to do this

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文