Tag Archive for replace

MySQL Mass Text/String Replace

UPDATE table_name SET column = REPLACE(column, 'old_text', 'new_text');

source

Image Replace for Buttons

#submitButton {
width: 38px;/* Width of button image */
height: 19px;/* Height of button image */
padding: 30px 0 0;
margin: 0;
border: 0;
background: transparent url(images/buttonimage.gif) no-repeat;
overflow: hidden;
cursor: pointer; /* hand-shaped cursor */
cursor: hand; /* for IE 5.x */
}

source

Regular expressions filename replace

// This will strip out any punctuation and spaces from filenames, replacing such characters with underscores
$filename = preg_replace("/[^a-zA-Z0-9s.]/", "_", $filename);

source

str_replace

	function str_replace( search, replace, string ):String{
var array = string.split(search);
return array.join(replace);
}

source

Search and replace text in a string

var newText:String = "The rain in Spain falls mainly on the plain";
var splitText:Array = newText.split("Spain");
newText = splitText.join("Barcelona");
// outputs "The rain in Barcelona falls mainly on the plain"

source

search and replace across multiple files with Perl

#print the result of search-and-replace to the terminal
perl -pe 's/bart/milhouse/g' test.html

#search-and-replace, with backup
#leave the suffix off of -i to overwrite
perl -i.bak -pe 's/bart/milhouse/g' test.html

#echo the number of lines in a file
perl -lne 'END { print $t } @w = /(w+)/g; $t += @w' test.html

#cat file with line numbers
# -p prints $_ each iteration
perl -pe '$_ = "$. = $_"' test.html

# recursive search-and-replace, only on shells that support file globs
perl -i.bak -pe 's{bart}{milhouse}' **/*html

source

String.replaceAll method implementation

String.prototype.replaceAll = function(pcFrom, pcTo){
var i = this.indexOf(pcFrom);
var c = this;

while (i > -1){
c = c.replace(pcFrom, pcTo);
i = c.indexOf(pcFrom);
}
return c;
}

source

actionscript crawler

I am looking for an actionscript crawler. I always need to go thru all the lines of code to find instance names and its linkage. Let me know of any good software for this purpose. I hate eclipse. I am a Mac. Let me know@.

source

Javascript search and replace

var str="foobar";
var val="foo";
var search='/'+val+'/i';
alert(str.replace(search, '<strong>'+val+'</strong>'));

// it alerts "foobar" and not "<strong>foo</strong>bar"

source

SELECT REPLACE

<?php

$query = "
SELECT
id, REPLACE(names,'".chr(29)."',', ') as namestring
FROM
table
";

?>

source