Author:
erics , July 22nd, 2021
PROBLEM: An element ID that looked like this would fail to match: service = east node = db1-demo.thedomain.com
< div style = "width: 50px; height: 50px; background: #00aa00; color: #000;" id = "Div-node-notes-east-db1-demo.thedomain.com" > Content to hide and show here < / div >
< a href = "#" onclick = "jQuery('#Div-node-notes-'+service+'-'+node.toggle();return false;" > Toggle Div < / a >
SOLUTION: Rig any special characters in the complex hostname (:.[],-@) with a backslash in front of them to ensure proper matching:
<script>
var G = { } ;
G . cleanid = function ( myid ) {
return myid . replace ( /(:|\.|\[|\]|,|=|@)/g , "\\$1" ) ;
}
</script>
< div style = "width: 50px; height: 50px; background: #00aa00; color: #000;" id = "Div-node-notes-east-db1-demo.thedomain.com" > Content to hide and show here < / div >
< a href = "#" onclick = "jQuery('#Div-node-notes-'+service+'-'+G.cleanid(node).toggle();return false;" > Toggle Div < / a >
Categories: How-To's , Technology Tags: ID , JQuery , Long , Match , onclick , Replace , Script
| No comments
Author:
erics , February 11th, 2021
## to add a single backslash in front of whatever char was matched
my $ password = q #abc'A1r%Fgt&jh[-#;
$ password = ~ s / ( [ '])/\\$1/g;
print qq#' $ password '\n#;
' abc \ 'A1r % Fgt & jh [ - '
## to double whatever char was matched
my $ password = q #abc'A1r%Fgt&jh[-#;
$ password = ~ s / ( [ '])/$1$1/g;
print qq#' $ password '\n#;
' abc '' A1r % Fgt & jh [ - '
## to convert ‘ to ‘\” for shell execution
my $ password = q #abc'A1r%Fgt&jh[-#;
$ passwordShell = ~ s / ( [ '])/$1\\$1$1/g;
print qq#' $ password '\n#;
' abc '\'' A1r % Fgt & jh [ - '
Categories: How-To's , Technology Tags: Backslash , Characters , double , double quotes , Escape , howto , perl , quote , quotes , Replace , Single , single quotes , Speci , Special , Special character , Substitute , tips
| No comments
Author:
erics , July 7th, 2015
To search for non-ASCII characters: /[^\d0-\d127] Use the substitute function to clean them up: :%s/[^\d0-\d127]/ /g
Categories: How-To's , Technology Tags: ASCII , Char , Characters , Find , howto , Replace , search , tips , vi , vim
| No comments
Author:
erics , October 16th, 2014
Using PERL, we can easily do a search and replace across multiple files. perl -pi -w -e ‘s/SEARCH_FOR/REPLACE_WITH/g;’ FILE_LIST The following example will replace all occurrences of “hello” with “goodbye” inside files ending with .txt:
perl - pi - w - e 's/hello/goodbye/g;' * . txt
To handle special characters, use the hex value. For example, to convert MS web files that use control characters: […]
Categories: How-To's , Technology Tags: Batch , howto , perl , Replace , search , tips
| No comments
Author:
erics , April 16th, 2012
yourUpdatedVar = yourOriginalVar . replace ( / \ n / g , '<br />' ) ;
Categories: How-To's , Technology Tags: howto , javascript , line break , Newline , Replace , Search and Replace , tips
| No comments
Author:
erics , February 6th, 2012
To convert FROM dev TO www:
use yourDatabase ;
UPDATE wp_options SET option_value = REPLACE ( option_value , 'dev.yourdomain.com' , 'www.yourdomain.com' ) ;
UPDATE wp_posts SET post_content = REPLACE ( post_content , 'dev.yourdomain.com' , 'www.yourdomain.com' ) ;
UPDATE wp_posts SET guid = REPLACE ( guid , 'dev.yourdomain.com' , 'www.yourdomain.com' ) ;
UPDATE wp_postmeta SET meta_value = REPLACE ( meta_value , 'dev.yourdomain.com' , 'www.yourdomain.com' ) ;
To convert FROM www TO dev:
UPDATE wp_options SET option_value = REPLACE ( option_value , 'www.yourdomain.com' , 'dev.yourdomain.com' ) ;
UPDATE wp_posts SET post_content = REPLACE ( post_content , 'www.yourdomain.com' , 'dev.yourdomain.com' ) ;
UPDATE wp_posts SET guid = REPLACE ( guid , 'www.yourdomain.com' , 'dev.yourdomain.com' ) ;
UPDATE wp_postmeta SET meta_value = REPLACE ( meta_value , 'www.yourdomain.com' , 'dev.yourdomain.com' ) ;
Categories: How-To's , Technology Tags: howto , mysql , Regex , Replace , tips , update , WordPress
| No comments