TRIM to remove Prefix and Suffix from a string

MySQL Trim
SELECT TRIM( BOTH 'XX' FROM 'XXplus2net.comXXX')// Output plus2net.comX
Arguments
BOTH
Remove matching string from trailing and leading part of the string
LEADING
Remove matching string from leading part of the string
TRAILING
Remove matching string from trailing part of the string
SELECT TRIM(BOTH 'XX' FROM 'XX.plus2net.com.XXX')// Output .plus2net.com.X
SELECT TRIM(LEADING 'www.' FROM 'www.plus2net.com')// Output plus2net.com
SELECT TRIM(LEADING 'XX' FROM 'XX.plus2net.com.XXX') // Output .plus2net.com.XXX
SELECT TRIM(TRAILING 'com' FROM 'plus2net.com')// Output plus2net.
SELECT TRIM(TRAILING 'XX' FROM 'XX.plus2net.com.XXX') // Output XX.plus2net.com.X
Without using any arguments we can remove blank space from both ends of the string.
SELECT TRIM(' plus2net.com ') // Output is plus2net.com

Case in sensitive replacement

TRIM is a case sensitive match and replacement function.
SELECT TRIM(BOTH 'XX' FROM 'xx.plus2net.com.XXX')// Output xx.plus2net.com.X
To make it case in sensitive function we will use LOWER or UPPER case functions.
SELECT TRIM(BOTH UPPER('XX') FROM UPPER('xx.plus2net.com.XXX')) // Output  .PLUS2NET.COM.X
By using LOWER
SELECT TRIM(BOTH LOWER('XX') FROM LOWER('xx.plus2net.com.XXX')) // Output .plus2net.com.x 

Subscribe to our mailing list

* indicates required
Subscribe to plus2net
Your Rating


Google+

Post Comment This is for short comments only. Use the forum for more discussions.




Subscribe to our mailing list

* indicates required
Subscribe to plus2net




HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2017 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer