Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Replace String

Former Member
0 Kudos

Hi all,

There are some string like these ;

aaa-bbb--ccc

aabbbb---cc

aaaabbccc

.....

how can replace - or -- or ---or -


or -


with one space? Could you send me the algorithm?

Best regards,

Munur

5 REPLIES 5

anuj_srivastava
Active Participant
0 Kudos

Hi Munur ,

you can use the command Replace all occurrences of.

let ur string be str = 'aabb-cc--'.

REPLACE ALL OCCURRENCES of '-' in str with space.

This can solve ur problem.

Regards,

Anuj

Former Member
0 Kudos

use statement

Replace all occurence of '-' in <your field> with space.

If the above single statement gives you too many spaces use the following lines.

Replace all occurence of '----' in <your field> with space.

Replace all occurence of '---' in <your field> with space.

Replace all occurence of '--' in <your field> with space.

Replace all occurence of '-' in <your field> with space.

This will definitely serve your purpose.

Regards,

Lalit Mohan Gupta.

Former Member
0 Kudos

Hi.

Use:

REPLACE ALL OCCURRENCES OF '-' IN str WITH SPACE.

and later, if you wish just ONE space,

CONDENSE str.

0 Kudos

Hi,

You can use regular expressions for that:

REPLACE ALL OCCURRENCES OF REGEX '-*' IN <your_string> WITH <replacement>.

This will replace caracters '-', '', '-', etc. in you string by the replacement string you specified.

Hope it helps.

Regards,

Tanguy

Former Member
0 Kudos

Enough.

Rob