<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://kb.rvmgroup.it/index.php?action=history&amp;feed=atom&amp;title=Sostituzione_di_stringhe_con_wildcard_in_vim</id>
	<title>Sostituzione di stringhe con wildcard in vim - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://kb.rvmgroup.it/index.php?action=history&amp;feed=atom&amp;title=Sostituzione_di_stringhe_con_wildcard_in_vim"/>
	<link rel="alternate" type="text/html" href="https://kb.rvmgroup.it/index.php?title=Sostituzione_di_stringhe_con_wildcard_in_vim&amp;action=history"/>
	<updated>2026-05-06T04:41:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://kb.rvmgroup.it/index.php?title=Sostituzione_di_stringhe_con_wildcard_in_vim&amp;diff=8276&amp;oldid=prev</id>
		<title>Gabriele.vivinetto: Created page with &quot;Se si vogliono cercare delle stringhe contenenti wildcard in vim, e sostituirle correttamente, occorre far suo delle backreference nelle regular expression.  La backreference si …&quot;</title>
		<link rel="alternate" type="text/html" href="https://kb.rvmgroup.it/index.php?title=Sostituzione_di_stringhe_con_wildcard_in_vim&amp;diff=8276&amp;oldid=prev"/>
		<updated>2012-01-16T16:09:22Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Se si vogliono cercare delle stringhe contenenti wildcard in vim, e sostituirle correttamente, occorre far suo delle backreference nelle regular expression.  La backreference si …&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Se si vogliono cercare delle stringhe contenenti wildcard in vim, e sostituirle correttamente, occorre far suo delle backreference nelle regular expression.&lt;br /&gt;
&lt;br /&gt;
La backreference si definisce con le parentesi quotate:&lt;br /&gt;
 \(mystring\)&lt;br /&gt;
e si richiamano con la loro occorrenza numerica quotata&lt;br /&gt;
 \1&lt;br /&gt;
&lt;br /&gt;
Ad esempio se si vogliono sostituire tutte le stringhe&lt;br /&gt;
 myhost01.mydomain.com&lt;br /&gt;
 myhost02.mydomain.com&lt;br /&gt;
&lt;br /&gt;
Con&lt;br /&gt;
 myhost01.mynewdomain.com&lt;br /&gt;
 myhost02.mynewdomain.com&lt;br /&gt;
&lt;br /&gt;
La parte della stringa da ricercare è&lt;br /&gt;
 myhost..\.mydomain&lt;br /&gt;
cioè &lt;br /&gt;
myhost due_caratteri_qualsiasi punto mydomain&lt;br /&gt;
&lt;br /&gt;
I due caratteri qualsiasi costituiscono la parte &amp;quot;variabile&amp;quot; che va memorizzata nella backreference, quindi la definiamo come&lt;br /&gt;
 myhost \(..\)\.mydomain&lt;br /&gt;
&lt;br /&gt;
E la richiamiamo con il suo numero nella stringa di sostituzione&lt;br /&gt;
 myhost\1.mynewdomain&lt;br /&gt;
&lt;br /&gt;
Quindi la regex di find and replace sarà&lt;br /&gt;
 :%s/myhost\(..\)\.mydomain/myhost\1.mynewdomain/gc&lt;br /&gt;
&lt;br /&gt;
Naturalmente se ci sono più stringhe &amp;quot;variabili&amp;quot;, so usano più backreference...&lt;br /&gt;
&lt;br /&gt;
==Riferimenti==&lt;br /&gt;
*[http://vim.wikia.com/wiki/Search_and_replace#Details Search and replace - Vim Tips Wiki]&lt;/div&gt;</summary>
		<author><name>Gabriele.vivinetto</name></author>
	</entry>
</feed>