replace quotes on all files

I want to replace all strings without string interpolation that uses double quote into single quote

for example:

<?php
require_once $__CFG_dir_lib . "systemconfiguration.php";
require_once $__CFG_dir_lib . "lib.php";
$bla = "test $a 123";
$x = '<a href="123">test</a>';
$y = "<a href='123'>\ntest</a>";

into:

<?php
require_once $__CFG_dir_lib . 'systemconfiguration.php';
require_once $__CFG_dir_lib . 'lib.php';
$bla = "test $a 123";
$x = '<a href="123">test</a>';
$y = "<a href='123'>\ntest</a>";

who can i do this using IntelliJ without clicking one by one

what i've tried was:

find: "([^"'$\\]+)"
replace: '\$1'

but it still replaces the $x example

Answers


Possible in Notepad++ (and any other editor that uses Perl or PCRE)

I notice you're doing this in a text editor. In most editors, it's going to be very hard. In an editor that uses the PCRE engine, we can do it like this:

Search: '[^']*'(*SKIP)(*F)|"((?:(?!\$\w)[^"'])*)"

Replace: '$1'

In the online demo, look at the substitutions in the bottom pane.


Need Your Help

Update Cells in an In Memory Data table

c# .net ado.net datatable dataset

Ok, the story so far is i have a datatable, about 10,000 lines or so. and about 150 columns per row. ao more or less 150.000 cells in this datatable. i have all updateing working fine

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.