Ecere SDK/eC Forums • View topic - String Manipulation




Ecere SDK/eC Forums

Ecere Developers Community

String Manipulation

Help with the Ecere cross platform system functionality: working with files, threads, timers, databases, etc.

String Manipulation

Postby redj » Sat Dec 15, 2012 7:52 pm

Hi all,

Let's ask and answer questions about string manipulation in eC/EcereSDK here.

-redj
redj
 
Posts: 107
Joined: Sun Jan 17, 2010 10:03 am

Re: String Manipulation

Postby redj » Sat Dec 15, 2012 7:56 pm

What's the best method to get rid of extra spaces in a string?

Please show method(s) to remove double, triple and so on space by a single space.
Including solution(s) that handle all space characters including tab or alternatively only actual spaces.

-redj
redj
 
Posts: 107
Joined: Sun Jan 17, 2010 10:03 am

Re: String Manipulation

Postby redj » Sun Dec 16, 2012 2:41 am

here's something:

sdk/extras/stringTools.ec

that works rather nicely:
Code: Select all
char * s = SingleFuncCharsCopy(" my    string   ", isspace, both, ' ');

also:
Code: Select all
char * s = SingleCharsCopy(" my    string   ", " \t\n\r!@#$%^&*()-=+{}[]|", both, ' ');

list of new functions:
Code: Select all
void SingleChars(char * string, char * output, char * chars, Trim trim, char alt)
char * SingleCharsCopy(char * string, char * chars, Trim trim, char alt)
void SingleFuncChars(char * string, char * output, int (*CharTest)(char), Trim trim, char alt)
char * SingleFuncCharsCopy(char * string, int (*CharTest)(char), Trim trim, char alt)

Enjoy!

-redj
redj
 
Posts: 107
Joined: Sun Jan 17, 2010 10:03 am


Return to System Library

Who is online

Users browsing this forum: No registered users and 1 guest

cron