{"id":3991,"date":"2024-09-12T14:32:22","date_gmt":"2024-09-12T06:32:22","guid":{"rendered":"https:\/\/five.co\/?p=3991"},"modified":"2026-05-07T08:41:50","modified_gmt":"2026-05-07T00:41:50","slug":"sql-remove-characters-from-string","status":"publish","type":"post","link":"https:\/\/preview-php85.dzine.org\/five\/blog\/sql-remove-characters-from-string\/","title":{"rendered":"SQL Remove Characters from String: A Comprehensive Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Data cleansing is a crucial aspect of database management and data analysis. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One common task in this process is removing unwanted characters from strings stored in database tables. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This article provides an in-depth look at various techniques to remove characters from strings using SQL, covering different database management systems and scenarios.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<div class=\"root-eb-toc-qo5pi wp-block-essential-blocks-table-of-contents\"><div class=\"eb-parent-wrapper eb-parent-eb-toc-qo5pi \"><div class=\"eb-toc-container eb-toc-qo5pi  eb-toc-is-not-sticky eb-toc-not-collapsible eb-toc-initially-not-collapsed eb-toc-scrollToTop style-1 list-style-none\" data-scroll-top=\"false\" data-scroll-top-icon=\"fas fa-angle-up\" data-collapsible=\"false\" data-sticky-hide-mobile=\"false\" data-sticky=\"false\" data-scroll-target=\"scroll_to_toc\" data-copy-link=\"false\" data-editor-type=\"\" data-hide-desktop=\"false\" data-hide-tab=\"false\" data-hide-mobile=\"false\" data-itemcollapsed=\"false\" data-highlight-scroll=\"false\"><div class=\"eb-toc-header\"><h2 class=\"eb-toc-title\">Table of Contents<\/h2><\/div><div class=\"eb-toc-wrapper \" data-headers=\"[{&quot;level&quot;:2,&quot;content&quot;:&quot;Why Remove Characters from Strings?&quot;,&quot;text&quot;:&quot;Why Remove Characters from Strings?&quot;,&quot;link&quot;:&quot;why-remove-characters-from-strings&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;General Approaches to Removing Characters&quot;,&quot;text&quot;:&quot;General Approaches to Removing Characters&quot;,&quot;link&quot;:&quot;general-approaches-to-removing-characters&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;1. Using REPLACE Function&quot;,&quot;text&quot;:&quot;1. Using REPLACE Function&quot;,&quot;link&quot;:&quot;1-using-replace-function&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;2. Using Regular Expressions&quot;,&quot;text&quot;:&quot;2. Using Regular Expressions&quot;,&quot;link&quot;:&quot;2-using-regular-expressions&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;MySQL (using REGEXP_REPLACE)&quot;,&quot;text&quot;:&quot;MySQL (using REGEXP_REPLACE)&quot;,&quot;link&quot;:&quot;mysql-using-regexp_replace&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;PostgreSQL (using REGEXP_REPLACE)&quot;,&quot;text&quot;:&quot;PostgreSQL (using REGEXP_REPLACE)&quot;,&quot;link&quot;:&quot;postgresql-using-regexp_replace&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Oracle (using REGEXP_REPLACE)&quot;,&quot;text&quot;:&quot;Oracle (using REGEXP_REPLACE)&quot;,&quot;link&quot;:&quot;oracle-using-regexp_replace&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;3. Using TRANSLATE Function&quot;,&quot;text&quot;:&quot;3. Using TRANSLATE Function&quot;,&quot;link&quot;:&quot;3-using-translate-function&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Oracle and PostgreSQL&quot;,&quot;text&quot;:&quot;Oracle and PostgreSQL&quot;,&quot;link&quot;:&quot;oracle-and-postgresql&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Database-Specific Techniques&quot;,&quot;text&quot;:&quot;Database-Specific Techniques&quot;,&quot;link&quot;:&quot;database-specific-techniques&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Microsoft SQL Server&quot;,&quot;text&quot;:&quot;Microsoft SQL Server&quot;,&quot;link&quot;:&quot;microsoft-sql-server&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Using REPLACE in a Loop&quot;,&quot;text&quot;:&quot;Using REPLACE in a Loop&quot;,&quot;link&quot;:&quot;using-replace-in-a-loop&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Using a User-Defined Function&quot;,&quot;text&quot;:&quot;Using a User-Defined Function&quot;,&quot;link&quot;:&quot;using-a-user-defined-function&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;MySQL&quot;,&quot;text&quot;:&quot;MySQL&quot;,&quot;link&quot;:&quot;mysql&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Using a Combination of Functions&quot;,&quot;text&quot;:&quot;Using a Combination of Functions&quot;,&quot;link&quot;:&quot;using-a-combination-of-functions&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;PostgreSQL&quot;,&quot;text&quot;:&quot;PostgreSQL&quot;,&quot;link&quot;:&quot;postgresql&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Using String_To_Array and Array_To_String&quot;,&quot;text&quot;:&quot;Using String_To_Array and Array_To_String&quot;,&quot;link&quot;:&quot;using-string_to_array-and-array_to_string&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Common Use Cases and Examples&quot;,&quot;text&quot;:&quot;Common Use Cases and Examples&quot;,&quot;link&quot;:&quot;common-use-cases-and-examples&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Removing Non-Alphanumeric Characters&quot;,&quot;text&quot;:&quot;Removing Non-Alphanumeric Characters&quot;,&quot;link&quot;:&quot;removing-non-alphanumeric-characters&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Removing Leading\\\/Trailing Spaces&quot;,&quot;text&quot;:&quot;Removing Leading\\\/Trailing Spaces&quot;,&quot;link&quot;:&quot;removing-leadingtrailing-spaces&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Removing HTML Tags&quot;,&quot;text&quot;:&quot;Removing HTML Tags&quot;,&quot;link&quot;:&quot;removing-html-tags&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Extracting Numbers from a String&quot;,&quot;text&quot;:&quot;Extracting Numbers from a String&quot;,&quot;link&quot;:&quot;extracting-numbers-from-a-string&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Handling Special Cases&quot;,&quot;text&quot;:&quot;Handling Special Cases&quot;,&quot;link&quot;:&quot;handling-special-cases&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Unicode Characters&quot;,&quot;text&quot;:&quot;Unicode Characters&quot;,&quot;link&quot;:&quot;unicode-characters&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Case Sensitivity&quot;,&quot;text&quot;:&quot;Case Sensitivity&quot;,&quot;link&quot;:&quot;case-sensitivity&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Conclusion&quot;,&quot;text&quot;:&quot;Conclusion&quot;,&quot;link&quot;:&quot;conclusion&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;FAQ&quot;,&quot;text&quot;:&quot;FAQ&quot;,&quot;link&quot;:&quot;faq&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;What is the easiest way to remove characters from a string in SQL?&quot;,&quot;text&quot;:&quot;What is the easiest way to remove characters from a string in SQL?&quot;,&quot;link&quot;:&quot;what-is-the-easiest-way-to-remove-characters-from-a-string-in-sql&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;How do you remove multiple or patterned characters in SQL?&quot;,&quot;text&quot;:&quot;How do you remove multiple or patterned characters in SQL?&quot;,&quot;link&quot;:&quot;how-do-you-remove-multiple-or-patterned-characters-in-sql&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Can you remove characters from only the beginning or end of a string?&quot;,&quot;text&quot;:&quot;Can you remove characters from only the beginning or end of a string?&quot;,&quot;link&quot;:&quot;can-you-remove-characters-from-only-the-beginning-or-end-of-a-string&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;How do you remove a fixed number of characters in SQL?&quot;,&quot;text&quot;:&quot;How do you remove a fixed number of characters in SQL?&quot;,&quot;link&quot;:&quot;how-do-you-remove-a-fixed-number-of-characters-in-sql&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Why is removing characters from strings important in SQL?&quot;,&quot;text&quot;:&quot;Why is removing characters from strings important in SQL?&quot;,&quot;link&quot;:&quot;why-is-removing-characters-from-strings-important-in-sql&quot;}]\" data-visible=\"[true,true,true,true,true,true]\" data-delete-headers=\"[{&quot;label&quot;:&quot;Why Remove Characters from Strings?&quot;,&quot;value&quot;:&quot;why-remove-characters-from-strings&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;General Approaches to Removing Characters&quot;,&quot;value&quot;:&quot;general-approaches-to-removing-characters&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;1. Using REPLACE Function&quot;,&quot;value&quot;:&quot;1-using-replace-function&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;2. Using Regular Expressions&quot;,&quot;value&quot;:&quot;2-using-regular-expressions&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;MySQL (using REGEXP_REPLACE)&quot;,&quot;value&quot;:&quot;mysql-using-regexp_replace&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;PostgreSQL (using REGEXP_REPLACE)&quot;,&quot;value&quot;:&quot;postgresql-using-regexp_replace&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Oracle (using REGEXP_REPLACE)&quot;,&quot;value&quot;:&quot;oracle-using-regexp_replace&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;3. Using TRANSLATE Function&quot;,&quot;value&quot;:&quot;3-using-translate-function&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Oracle and PostgreSQL&quot;,&quot;value&quot;:&quot;oracle-and-postgresql&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Database-Specific Techniques&quot;,&quot;value&quot;:&quot;database-specific-techniques&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Microsoft SQL Server&quot;,&quot;value&quot;:&quot;microsoft-sql-server&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Using REPLACE in a Loop&quot;,&quot;value&quot;:&quot;using-replace-in-a-loop&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Using a User-Defined Function&quot;,&quot;value&quot;:&quot;using-a-user-defined-function&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;MySQL&quot;,&quot;value&quot;:&quot;mysql&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Using a Combination of Functions&quot;,&quot;value&quot;:&quot;using-a-combination-of-functions&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;PostgreSQL&quot;,&quot;value&quot;:&quot;postgresql&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Using String_To_Array and Array_To_String&quot;,&quot;value&quot;:&quot;using-string_to_array-and-array_to_string&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Common Use Cases and Examples&quot;,&quot;value&quot;:&quot;common-use-cases-and-examples&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Removing Non-Alphanumeric Characters&quot;,&quot;value&quot;:&quot;removing-non-alphanumeric-characters&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Removing Leading\\\/Trailing Spaces&quot;,&quot;value&quot;:&quot;removing-leadingtrailing-spaces&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Removing HTML Tags&quot;,&quot;value&quot;:&quot;removing-html-tags&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Extracting Numbers from a String&quot;,&quot;value&quot;:&quot;extracting-numbers-from-a-string&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Handling Special Cases&quot;,&quot;value&quot;:&quot;handling-special-cases&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Unicode Characters&quot;,&quot;value&quot;:&quot;unicode-characters&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Case Sensitivity&quot;,&quot;value&quot;:&quot;case-sensitivity&quot;,&quot;isDelete&quot;:true},{&quot;label&quot;:&quot;Conclusion&quot;,&quot;value&quot;:&quot;conclusion&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;FAQ&quot;,&quot;value&quot;:&quot;faq&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;What is the easiest way to remove characters from a string in SQL?&quot;,&quot;value&quot;:&quot;what-is-the-easiest-way-to-remove-characters-from-a-string-in-sql&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;How do you remove multiple or patterned characters in SQL?&quot;,&quot;value&quot;:&quot;how-do-you-remove-multiple-or-patterned-characters-in-sql&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Can you remove characters from only the beginning or end of a string?&quot;,&quot;value&quot;:&quot;can-you-remove-characters-from-only-the-beginning-or-end-of-a-string&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;How do you remove a fixed number of characters in SQL?&quot;,&quot;value&quot;:&quot;how-do-you-remove-a-fixed-number-of-characters-in-sql&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Why is removing characters from strings important in SQL?&quot;,&quot;value&quot;:&quot;why-is-removing-characters-from-strings-important-in-sql&quot;,&quot;isDelete&quot;:false}]\" data-smooth=\"true\" data-top-offset=\"\"><div class=\"eb-toc__list-wrap\"><ul class=\"eb-toc__list\"><li><a href=\"#why-remove-characters-from-strings\">Why Remove Characters from Strings?<\/a><li><a href=\"#general-approaches-to-removing-characters\">General Approaches to Removing Characters<\/a><li><a href=\"#database-specific-techniques\">Database-Specific Techniques<\/a><li><a href=\"#common-use-cases-and-examples\">Common Use Cases and Examples<\/a><li><a href=\"#handling-special-cases\">Handling Special Cases<\/a><li><a href=\"#conclusion\">Conclusion<\/a><li><a href=\"#faq\">FAQ<\/a><ul class=\"eb-toc__list\"><li><a href=\"#what-is-the-easiest-way-to-remove-characters-from-a-string-in-sql\">What is the easiest way to remove characters from a string in SQL?<\/a><li><a href=\"#how-do-you-remove-multiple-or-patterned-characters-in-sql\">How do you remove multiple or patterned characters in SQL?<\/a><li><a href=\"#can-you-remove-characters-from-only-the-beginning-or-end-of-a-string\">Can you remove characters from only the beginning or end of a string?<\/a><li><a href=\"#how-do-you-remove-a-fixed-number-of-characters-in-sql\">How do you remove a fixed number of characters in SQL?<\/a><li><a href=\"#why-is-removing-characters-from-strings-important-in-sql\">Why is removing characters from strings important in SQL?<\/a><\/li><\/ul><\/ul><\/div><\/div><\/div><\/div><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div style=\"background-color: #001524;\"><hr style=\"height: 5px;\" \/>\n<pre style=\"text-align: center; overflow: hidden; white-space: pre-line;\"><span style=\"color: #f1ebda; background-color: #4588d8; font-size: calc(25px + 0.390625vw);\"><strong>SQL Made Simple - Try Five<\/strong><br \/><span style=\"font-size: 14pt;\">Five is the Easiest Way to Create, Model and Query a SQL Database<\/span><\/span><\/pre>\n<p style=\"text-align: center;\"><a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\" target=\"_blank\" rel=\"noopener\"><button style=\"background-color: #f8b92b; border: none; color: black; padding: 20px; text-align: center; text-decoration: none; display: inline-block; font-size: 18px; cursor: pointer; margin: 4px 2px; border-radius: 5px;\"><strong>Get Started<\/strong><\/button><\/a><br \/><span style=\"color: #ffffff; font-size: revert;\">___<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"text-decoration: underline;\"><strong><span style=\"color: #ffffff; text-decoration: underline;\">Here&#8217;s What You Can Do With Five<\/span><\/strong><\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"color: #ffffff;\">Create and Model a SQL Database \u2705<br \/>Write or Build SQL Queries \u2705<br \/>Visualize Queries as Charts or in Dashboards \u2705<br \/>Add CRUD Permissions to Control Data Access \u2705<br \/>Host Your Database Online \u2705\u00a0<\/span><\/p>\n<p style=\"text-align: center;\"><span style=\"color: #f1ebda; background-color: #4588d8;\"><em><strong>&#8220;Five bridges the gap between SQL and the web, <br \/>allowing me to create full-stack applications almost entirely in SQL&#8221;<\/strong><\/em><\/span><br \/><span style=\"color: #ffffff;\">&#8211; Crag Jones, Database Administrator (DBA)<\/span><\/p>\n<hr style=\"height: 5px;\" \/><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Why Remove Characters from Strings?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are several reasons why you might need to remove characters from strings in your database:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Data Standardization<\/strong>: Ensuring consistency across data entries.<\/li>\n\n\n\n<li><strong>Data Cleaning<\/strong>: Removing unwanted or erroneous characters.<\/li>\n\n\n\n<li><strong>Text Processing<\/strong>: Preparing text for analysis or display.<\/li>\n\n\n\n<li><strong>Compliance<\/strong>: Meeting specific data format requirements.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s explore various methods to accomplish this task across different SQL database systems.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">General Approaches to Removing Characters<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Using REPLACE Function<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The REPLACE function is available in most SQL databases and is useful for removing specific characters or substrings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>REPLACE(string, substring_to_remove, replacement_string)<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #56B6C2\">REPLACE<\/span><span style=\"color: #ABB2BF\">(string, substring_to_remove, replacement_string)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Example (removing spaces):<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>SELECT REPLACE('Hello World', ' ', '') AS Result;\n-- Output: HelloWorld<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">REPLACE<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&#39;Hello World&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39; &#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: HelloWorld<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">2. Using Regular Expressions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Regular expressions (regex) provide a powerful way to remove patterns of characters. The implementation varies across database systems.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">MySQL (using REGEXP_REPLACE)<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>SELECT REGEXP_REPLACE('Hello123World', '&#091;0-9&#093;', '') AS Result;\n-- Output: HelloWorld<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> REGEXP_REPLACE(<\/span><span style=\"color: #98C379\">&#39;Hello123World&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#091;0-9&#093;&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: HelloWorld<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">PostgreSQL (using REGEXP_REPLACE)<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>SELECT REGEXP_REPLACE('Hello123World', '\\d', '', 'g') AS Result;\n-- Output: HelloWorld<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> REGEXP_REPLACE(<\/span><span style=\"color: #98C379\">&#39;Hello123World&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;\\d&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;g&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: HelloWorld<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Oracle (using REGEXP_REPLACE)<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>SELECT REGEXP_REPLACE('Hello123World', '&#091;0-9&#093;') AS Result FROM DUAL;\n-- Output: HelloWorld<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> REGEXP_REPLACE(<\/span><span style=\"color: #98C379\">&#39;Hello123World&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#091;0-9&#093;&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result <\/span><span style=\"color: #C678DD\">FROM<\/span><span style=\"color: #ABB2BF\"> DUAL;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: HelloWorld<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">3. Using TRANSLATE Function<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Some databases offer a TRANSLATE function, which is useful for removing multiple specific characters.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Oracle and PostgreSQL<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>SELECT TRANSLATE('Hello123World', '0123456789', '') AS Result;\n-- Output: HelloWorld<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">TRANSLATE<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&#39;Hello123World&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;0123456789&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: HelloWorld<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Database-Specific Techniques<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Microsoft SQL Server<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">SQL Server doesn&#8217;t have a built-in regex function, but it offers other methods for removing characters.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Using REPLACE in a Loop<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>DECLARE @String VARCHAR(50) = 'Hello123World';\nDECLARE @Pattern VARCHAR(50) = '0123456789';\nDECLARE @i INT = 1;\n\nWHILE @i &lt;= LEN(@Pattern)\nBEGIN\n    SET @String = REPLACE(@String, SUBSTRING(@Pattern, @i, 1), '');\n    SET @i = @i + 1;\nEND\n\nSELECT @String AS Result;\n-- Output: HelloWorld<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">DECLARE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@String<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">50<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #98C379\">&#39;Hello123World&#39;<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">DECLARE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@Pattern<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #D19A66\">50<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #98C379\">&#39;0123456789&#39;<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">DECLARE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@i<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">INT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #D19A66\">1<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">WHILE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@i<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">&lt;=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">LEN<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">@Pattern<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">BEGIN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">SET<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@String<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">REPLACE<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">@String<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #56B6C2\">SUBSTRING<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">@Pattern<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75\">@i<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #D19A66\">1<\/span><span style=\"color: #ABB2BF\">), <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">SET<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@i<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@i<\/span><span style=\"color: #ABB2BF\"> + <\/span><span style=\"color: #D19A66\">1<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">END<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@String<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: HelloWorld<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Using a User-Defined Function<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Create a function to remove characters:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>CREATE FUNCTION dbo.RemoveCharacters\n(\n    @String VARCHAR(MAX),\n    @CharactersToRemove VARCHAR(MAX)\n)\nRETURNS VARCHAR(MAX)\nAS\nBEGIN\n    DECLARE @i INT = 1;\n    WHILE @i &lt;= LEN(@CharactersToRemove)\n    BEGIN\n        SET @String = REPLACE(@String, SUBSTRING(@CharactersToRemove, @i, 1), '');\n        SET @i = @i + 1;\n    END\n    RETURN @String;\nEND;<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">CREATE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">FUNCTION<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #61AFEF\">dbo<\/span><span style=\"color: #ABB2BF\">.RemoveCharacters<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E06C75\">@String<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(MAX),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #E06C75\">@CharactersToRemove<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(MAX)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">RETURNS<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">VARCHAR<\/span><span style=\"color: #ABB2BF\">(MAX)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">AS<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">BEGIN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">DECLARE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@i<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">INT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #D19A66\">1<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">WHILE<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@i<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">&lt;=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">LEN<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">@CharactersToRemove<\/span><span style=\"color: #ABB2BF\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">BEGIN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">SET<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@String<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">REPLACE<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">@String<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #56B6C2\">SUBSTRING<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #E06C75\">@CharactersToRemove<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #E06C75\">@i<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #D19A66\">1<\/span><span style=\"color: #ABB2BF\">), <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">SET<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@i<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">=<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@i<\/span><span style=\"color: #ABB2BF\"> + <\/span><span style=\"color: #D19A66\">1<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">END<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">RETURN<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #E06C75\">@String<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">END<\/span><span style=\"color: #ABB2BF\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Use the function:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>SELECT dbo.RemoveCharacters('Hello123World', '0123456789') AS Result;\n-- Output: HelloWorld<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #D19A66\">dbo<\/span><span style=\"color: #ABB2BF\">.<\/span><span style=\"color: #D19A66\">RemoveCharacters<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&#39;Hello123World&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;0123456789&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: HelloWorld<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">MySQL<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">MySQL offers several built-in string functions that can be combined for character removal.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Using a Combination of Functions<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>SELECT \n    REGEXP_REPLACE(\n        TRIM(\n            BOTH ' ' FROM 'Hello123 World '\n        ),\n        '&#091;0-9&#093;',\n        ''\n    ) AS Result;\n-- Output: Hello World<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    REGEXP_REPLACE(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #56B6C2\">TRIM<\/span><span style=\"color: #ABB2BF\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #C678DD\">BOTH<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #98C379\">&#39; &#39;<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">FROM<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #98C379\">&#39;Hello123 World &#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        ),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #98C379\">&#39;&#091;0-9&#093;&#39;<\/span><span style=\"color: #ABB2BF\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    ) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: Hello World<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">PostgreSQL<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">PostgreSQL provides powerful string manipulation functions, including regex support.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Using String_To_Array and Array_To_String<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>SELECT array_to_string(\n    ARRAY(\n        SELECT unnest(string_to_array('Hello123World', NULL))\n        WHERE ordinality NOT IN (\n            SELECT ordinality\n            FROM unnest(string_to_array('Hello123World', NULL)) WITH ORDINALITY\n            WHERE unnest ~ '&#091;0-9&#093;'\n        )\n    ),\n    ''\n) AS Result;\n-- Output: HelloWorld<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> array_to_string(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #C678DD\">ARRAY<\/span><span style=\"color: #ABB2BF\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> unnest(string_to_array(<\/span><span style=\"color: #98C379\">&#39;Hello123World&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #C678DD\">NULL<\/span><span style=\"color: #ABB2BF\">))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        <\/span><span style=\"color: #C678DD\">WHERE<\/span><span style=\"color: #ABB2BF\"> ordinality <\/span><span style=\"color: #C678DD\">NOT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #C678DD\">IN<\/span><span style=\"color: #ABB2BF\"> (<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> ordinality<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #C678DD\">FROM<\/span><span style=\"color: #ABB2BF\"> unnest(string_to_array(<\/span><span style=\"color: #98C379\">&#39;Hello123World&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #C678DD\">NULL<\/span><span style=\"color: #ABB2BF\">)) <\/span><span style=\"color: #C678DD\">WITH<\/span><span style=\"color: #ABB2BF\"> ORDINALITY<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">            <\/span><span style=\"color: #C678DD\">WHERE<\/span><span style=\"color: #ABB2BF\"> unnest ~ <\/span><span style=\"color: #98C379\">&#39;&#091;0-9&#093;&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">        )<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    ),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">    <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: HelloWorld<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\"><strong style=\"background-color: rgb(69, 136, 216); color: rgb(241, 235, 218); font-size: calc(12px + 0.390625vw); font-weight: bold;\">Remove Characters from String with a Rapid Database Builder<\/strong><\/mark><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While understanding SQL and executing efficient queries isn&#8217;t too difficult, removing characters from a string in SQL can sometimes require extra attention, especially when working with large datasets or formatting text outputs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>This is where rapid database builders like Five come into play. Five provides a MySQL database for your <a href=\"https:\/\/preview-php85.dzine.org\/five\/blog\/how-to-build-a-web-app\/\">application<\/a> and generates an automatic UI, making it easier to interact with your data.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With Five, you can handle tasks like removing characters from strings intuitively through its generated forms and tables, allowing you to focus on writing accurate queries without worrying about manual string manipulation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Five also enables you to create interactive forms, tables, dynamic charts, comprehensive PDF reports, and dashboards that are automatically generated based on your database schema.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In addition, Five lets you write custom JavaScript and TypeScript functions, giving you the flexibility to implement complex business logic, such as advanced string operations and data transformations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once your application is ready, Five makes deployment easy with just a few clicks, allowing you to deploy your MySQL-based application to a secure, scalable cloud infrastructure.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This lets you focus on developing, while Five handles the complexities of cloud deployment and infrastructure management.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;re serious about using SQL efficiently, give Five a try.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\/\">Sign up for free access to Five\u2019s online development environment and start building your MySQL web application today.<\/a><\/p>\n\n\n\n<div style=\"background-color: #001524;\"><hr style=\"height: 5px;\" \/>\n<pre style=\"text-align: center; overflow: hidden; white-space: pre-line;\"><span style=\"color: #f1ebda; background-color: #4588d8; font-size: calc(18px + 0.390625vw);\"><strong>Build Your Database In 3 Steps<\/strong><br \/><span style=\"font-size: 14pt;\">Start Developing Today<\/span><\/span><\/pre>\n<p style=\"text-align: center;\"><a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\" target=\"_blank\" rel=\"noopener\" data-wplink-edit=\"true\"><button style=\"background-color: #f8b92b; border: none; color: black; padding: 20px; text-align: center; text-decoration: none; display: inline-block; font-size: 18px; cursor: pointer; margin: 4px 2px; border-radius: 5px;\"><strong>Get Instant Access<\/strong><\/button><br \/><\/a><\/p>\n<hr style=\"height: 5px;\" \/><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Common Use Cases and Examples<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Removing Non-Alphanumeric Characters<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>-- PostgreSQL\nSELECT REGEXP_REPLACE('Hello, World! 123', '&#091;^a-zA-Z0-9&#093;', '', 'g') AS Result;\n-- Output: HelloWorld123<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- PostgreSQL<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> REGEXP_REPLACE(<\/span><span style=\"color: #98C379\">&#39;Hello, World! 123&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#091;^a-zA-Z0-9&#093;&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;g&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: HelloWorld123<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Removing Leading\/Trailing Spaces<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>-- Standard SQL\nSELECT TRIM(' Hello World ') AS Result;\n-- Output: Hello World<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Standard SQL<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> <\/span><span style=\"color: #56B6C2\">TRIM<\/span><span style=\"color: #ABB2BF\">(<\/span><span style=\"color: #98C379\">&#39; Hello World &#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: Hello World<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Removing HTML Tags<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>-- MySQL\nSELECT REGEXP_REPLACE('&lt;p>Hello &lt;b>World&lt;\/b>&lt;\/p>', '&lt;&#091;^>&#093;+>', '') AS Result;\n-- Output: Hello World<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- MySQL<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> REGEXP_REPLACE(<\/span><span style=\"color: #98C379\">&#39;&lt;p&gt;Hello &lt;b&gt;World&lt;\/b&gt;&lt;\/p&gt;&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&lt;&#091;^&gt;&#093;+&gt;&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: Hello World<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Extracting Numbers from a String<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>-- PostgreSQL\nSELECT REGEXP_REPLACE('ABC123DEF456', '\\D', '', 'g') AS Result;\n-- Output: 123456<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- PostgreSQL<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> REGEXP_REPLACE(<\/span><span style=\"color: #98C379\">&#39;ABC123DEF456&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;\\D&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;g&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: 123456<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Handling Special Cases<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Unicode Characters<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When dealing with Unicode characters, ensure your database and queries are properly configured to handle them.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>-- MySQL (with proper character set)\nSELECT REGEXP_REPLACE('Hello\u4e16\u754c123', '&#091;^a-zA-Z&#093;', '') AS Result;\n-- Output: Hello<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- MySQL (with proper character set)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> REGEXP_REPLACE(<\/span><span style=\"color: #98C379\">&#39;Hello\u4e16\u754c123&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#091;^a-zA-Z&#093;&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: Hello<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Case Sensitivity<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Consider case sensitivity in your removal operations:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#abb2bf;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282c34\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#abb2bf;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>-- PostgreSQL (case-insensitive removal)\nSELECT REGEXP_REPLACE('HeLLo WoRLd', 'l', '', 'gi') AS Result;\n-- Output: Heo WoRd<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki one-dark-pro\" style=\"background-color: #282c34\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- PostgreSQL (case-insensitive removal)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C678DD\">SELECT<\/span><span style=\"color: #ABB2BF\"> REGEXP_REPLACE(<\/span><span style=\"color: #98C379\">&#39;HeLLo WoRLd&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;l&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;&#39;<\/span><span style=\"color: #ABB2BF\">, <\/span><span style=\"color: #98C379\">&#39;gi&#39;<\/span><span style=\"color: #ABB2BF\">) <\/span><span style=\"color: #C678DD\">AS<\/span><span style=\"color: #ABB2BF\"> Result;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #7F848E; font-style: italic\">-- Output: Heo WoRd<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div style=\"height:21px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Removing characters from strings in SQL is a fundamental skill for data cleaning and manipulation. By understanding and applying the techniques discussed in this article, you can effectively manage and process string data across various database systems.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/preview-php85.dzine.org\/five\/get-started\/\">Sign up for free access to Five\u2019s online development environment and start building your MySQL web application today.<\/a><\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<ol class=\"rank-math-list \">\n<li id=\"faq-question-1771985858796\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>What is the easiest way to remove characters from a string in SQL?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>The simplest method is using the <strong>REPLACE()<\/strong> function, which substitutes a character or substring with another value (often an empty string). This function is widely supported across SQL databases and is ideal for removing specific characters like spaces or symbols.<\/p>\n\n<\/div>\n<\/li>\n<li id=\"faq-question-1771985909936\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong><strong>How do you remove multiple or patterned characters in SQL?<\/strong><\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>To remove patterns such as digits or special characters, you can use <strong>regular expressions<\/strong> (e.g., <code>REGEXP_REPLACE<\/code>). Regex allows you to target character groups instead of removing them one by one, making it more efficient for complex cleaning tasks.<\/p>\n\n<\/div>\n<\/li>\n<li id=\"faq-question-1771985985770\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>Can you remove characters from only the beginning or end of a string?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Yes. The <strong>TRIM()<\/strong> function removes characters from the start, end, or both sides of a string. You can specify options like <code>LEADING<\/code>, <code>TRAILING<\/code>, or <code>BOTH<\/code> depending on where you want the characters removed.<\/p>\n\n<\/div>\n<\/li>\n<li id=\"faq-question-1771985994514\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong><strong>How do you remove a fixed number of characters in SQL?<\/strong><\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>You can combine <strong>SUBSTRING()<\/strong> with a length function (like <code>LEN()<\/code> in SQL Server) to return only part of a string. This approach is useful when you need to remove a set number of characters from the beginning or end.<\/p>\n\n<\/div>\n<\/li>\n<li id=\"faq-question-1771986003404\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong><strong>Why is removing characters from strings important in SQL?<\/strong><\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Cleaning strings is essential for <strong>data quality and formatting<\/strong>, such as preparing text for analysis, ensuring consistent formats, or removing unwanted symbols before processing. These operations help maintain accurate and usable datasets.<\/p>\n\n<\/div>\n<\/li>\n<\/ol>\n<\/div><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Data cleansing is a crucial aspect of database management and data analysis. One common task in this process is removing unwanted characters from strings stored in database tables. This article provides an in-depth look at various techniques to remove characters from strings using SQL, covering different database management systems and scenarios. SQL Made Simple &#8211; [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":3995,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_eb_attr":"","_uag_custom_page_level_css":"","footnotes":""},"categories":[21],"tags":[],"class_list":["post-3991","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"uagb_featured_image_src":{"full":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/09\/Five.Co-SQL-Remove-Characters-from-String.png",1280,720,false],"thumbnail":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/09\/Five.Co-SQL-Remove-Characters-from-String-150x150.png",150,150,true],"medium":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/09\/Five.Co-SQL-Remove-Characters-from-String-300x169.png",300,169,true],"medium_large":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/09\/Five.Co-SQL-Remove-Characters-from-String-768x432.png",768,432,true],"large":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/09\/Five.Co-SQL-Remove-Characters-from-String-1024x576.png",1024,576,true],"1536x1536":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/09\/Five.Co-SQL-Remove-Characters-from-String.png",1280,720,false],"2048x2048":["https:\/\/preview-php85.dzine.org\/five\/wp-content\/uploads\/2024\/09\/Five.Co-SQL-Remove-Characters-from-String.png",1280,720,false]},"uagb_author_info":{"display_name":"Ryan Forrester","author_link":"https:\/\/preview-php85.dzine.org\/five\/author\/f1v5_ed9_au\/"},"uagb_comment_info":0,"uagb_excerpt":"Data cleansing is a crucial aspect of database management and data analysis. One common task in this process is removing unwanted characters from strings stored in database tables. This article provides an in-depth look at various techniques to remove characters from strings using SQL, covering different database management systems and scenarios. SQL Made Simple -&hellip;","_links":{"self":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts\/3991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/comments?post=3991"}],"version-history":[{"count":1,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts\/3991\/revisions"}],"predecessor-version":[{"id":17831,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/posts\/3991\/revisions\/17831"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/media\/3995"}],"wp:attachment":[{"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/media?parent=3991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/categories?post=3991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/preview-php85.dzine.org\/five\/wp-json\/wp\/v2\/tags?post=3991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}