This forum is currently locked. You can't register or post questions at this time. (read more)

Is there a function to eat extra spaces in a string?

All posts relating to Oracle PL/SQL development.

Moderator: Tim...

mode09
Member
Posts: 17
Joined: Wed Jul 16, 2008 3:19 pm

Is there a function to eat extra spaces in a string?

Postby mode09 » Thu Jan 31, 2013 7:03 pm

I know about rtrim, ltrim commands, but what I was interested in was a way to eat extra spaces also contained within strings.


For example:
myString = ' The dog is out side the house . ';

Is there a function that will keep one space between each word so the final result would be:
'The dog is outside the house.'

Tim...
Site Admin
Posts: 18437
Joined: Mon Nov 01, 2004 5:56 pm
Location: England, UK
Contact:

Re: Is there a function to eat extra spaces in a string?

Postby Tim... » Thu Jan 31, 2013 9:04 pm

Hi.

What about,

Code: Select all

Replace(variable, '  ', ' ')


If you think you might have more than two together, you could use regexp_replace.

Cheers

Tim...
Tim...
Oracle ACE Director
Oracle ACE of the Year 2006 - Oracle Magazine Editors Choice Awards
OakTable Member
OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
OCP Advanced PL/SQL Developer
Oracle Database: SQL Certified Expert
My website: http://www.oracle-base.com
My blog: http://www.oracle-base.com/blog


Return to “Oracle SQL and PL/SQL Development”

Who is online

Users browsing this forum: No registered users and 2 guests