How to replace multiple spaces with one space?

I came up with the situation of replacing multiple spaces with single space in SQL. I got the solution from a site but it was very difficult to understand at first look. So I got into deep to find out exactly how it works?

I really liked the trick and it made me write this blog post. This could be useful where regex expressions are not available.

The logic is explained in the video below. For visualization purpose space is represented as ‘@’ character and ‘#’ can be any random character which never occurs in strings as a normal character.

I am repeating again,
@ = white space
# = any random character that is never used as a normal character in strings.

replace( trim(‘string’) , ‘@@’,’@#’ )

By the way the editor utility which I am using in this video is Notepad++ which is free and open source editor and a video utility to create video which I used is CamStudio it is also free and open source.


Jackie Co Kad said…
Great Article
android based projects

Java Training in Chennai

Project Center in Chennai

Java Training in Chennai

projects for cse

The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing,

and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training Project Centers in Chennai

Android Final Year Project Ideas for Computer Science. IEEE Android Projects for CSE 2020 - 2021 - WISEN

Popular posts from this blog

How to get local time from UTC using Moment.JS

Step by step Cordova calabash-ios automation

Measure the height of keyboard on PhoneGap app using jQuery