How To Use Regex Negative Lookahead To Exclude Strings

Author: , 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:

To capture the files WITHOUT the _from_ string was not quite […]

How To Select the Max Numeric in a Varchar Column in MySQL

Author: , 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(): […]

How To Use Regular Expressions (regex) To Forward Email In Postfix

Author: , 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:

Edit the file /etc/postfix/main.cf. Add regexp:/etc/postfix/virtual-regexp to the virtual_alias_maps line. For example:

Generate the map .db file:

This example requires the files virtual and virtual.db to exist, even if they are […]

How To Select Only Numeric Values From MySQL

Author: , September 6th, 2012

How To Easily Update Your WordPress URL After A Server Move

Author: , February 6th, 2012

To convert FROM dev TO www:

To convert FROM www TO dev:

How To Use Regular Expressions In JavaScript

Author: , November 3rd, 2011

RegExp.exec(string) Applies the RegExp to the given string, and returns the match information.

match then contains [“Sample”,”amp”] RegExp.test(string) Tests if the given string matches the Regexp, and returns true if matching, false if not.

match then contains false String.match(pattern) Matches given string with the RegExp. With g flag returns an array containing the […]

How To Match Multiple Spaces In VIM

Author: , 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 […]