Author:
erics , May 31st, 2019
I have a task in Perl to list specific files based on pattern match, those with and those without the string “_from_”. There are two files in the directory to filter: static-east.properties static-east_from_west.properties To capture the files with the _from_ string was easy:
/ ^ static - ( . * ? ) _from_ ( . * ? ) \ . properties $ /
To capture the files WITHOUT the _from_ string was not quite […]
Categories: How-To's , Technology Tags: exclude , howto , Lookahead , Negative , Negative Lookahead , perl , Regex , tips , without
| No comments
Author:
erics , October 2nd, 2015
I needed to automate the addition of new users with a sequential member’s ID in WordPress. Additionally, there were non-numeric entries in that column that had to be ignored. The wp_users.user_login column is a varchar(60) and so does not naturally handle numeric operations well at all. The solution is a combination of REGEXP and cast(): […]
Categories: How-To's , Technology Tags: Cast , Char , Column , Filter , howto , Max , mysql , Numeric , Regex , regexp , select , sort , SQL , tips , Varchar , Where , WordPress
| No comments
Author:
erics , April 7th, 2015
Create the file /etc/postfix/virtual-regexp. For example, forward all emails with a leading eric and ending with @thewyz.net to a Gmail account:
/ eric . * / @ thewyz . net wyzaerd @ gmail . com
Edit the file /etc/postfix/main.cf. Add regexp:/etc/postfix/virtual-regexp to the virtual_alias_maps line. For example:
virtual_alias_maps = hash : / etc / postfix / virtual , regexp : / etc / postfix / virtual - regexp
Generate the map .db file:
postmap / etc / postfix / virtual - regexp
This example requires the files virtual and virtual.db to exist, even if they are […]
Categories: How-To's , Technology Tags: Email , Expression , Forward , howto , main.cf , PostFix , Regex , Regular , Regular Expression , Regular Expressions , tips , Virtual , virtual_alias_maps , virtual.db
| 2 comments
Author:
erics , September 6th, 2012
select field from table where field REGEXP '^-?[0-9]+$' ;
Categories: How-To's , Technology Tags: howto , mysql , Numeric , Regex , select , 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
Author:
erics , November 3rd, 2011
RegExp.exec(string) Applies the RegExp to the given string, and returns the match information.
var match = / s ( amp ) le / i . exec ( "Sample text" )
match then contains [“Sample”,”amp”] RegExp.test(string) Tests if the given string matches the Regexp, and returns true if matching, false if not.
var match = / sample / . test ( "Sample text" )
match then contains false String.match(pattern) Matches given string with the RegExp. With g flag returns an array containing the […]
Categories: Rants Tags: howto , javascript , JQuery , JS , Regex , Regular Expressions , tips
| No comments
Author:
erics , July 22nd, 2011
I needed to take just the first occurrence of one or more spaces and turn that into a pipe symbol so as to create 2 fields for easy database import:
The important thing to note is the inclusion of the backslash in front of the plus (+) sign. That prevents an irritating session of […]
Categories: How-To's , Technology Tags: grep , howto , Import , Match , mysql , Regex , Substitute , tips , Translate , vim
| No comments