forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Manipulating strings to remove certain words? Quick Question

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Tue Mar 07, 2006 2:04 pm    Post subject: Manipulating strings to remove certain words? Quick Question Reply with quote

I have been wanting to know, how do you/I manipulate / edit a string/buffer to remove certain words? EX:

Code:

BEFORE:
sprintf(buffer, "You're weird and this is an example.");
printf(buffer);

AFTER:
sprintf(buffer, "weird example");
printf(buffer);

What was removed was:

-You're
-and
-this
-is
-an

I have looked into the token string manipulative and that only removes certain characters, not words.

Also, if its easier, Im just in need of removing about 50 characters/words at the beginning and after of the string. Later I will need to substitute a series of characters as someting else, but I can make a strcpy and if they match, replace it with what I need. Please help, or atleast point me to a place that has EVERYTHING about strings and how to change/manipulate them. I know Im asking somewhat alot, but itd really help if i got an answer or some explanation of what to do. Thanks.
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Tue Mar 07, 2006 8:10 pm    Post subject: Reply with quote

trying to code a 'nanny'?
player types: "stupid fuck!"
game sends: "stupid $%&$"

greets
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
fish



Joined: 08 Feb 2006
Posts: 25

PostPosted: Tue Mar 07, 2006 9:08 pm    Post subject: Re: Manipulating strings to remove certain words? Quick Ques Reply with quote

sg57 wrote:
I have been wanting to know, how do you/I manipulate / edit a string/buffer to remove certain words? EX:

Code:

BEFORE:
sprintf(buffer, "You're weird and this is an example.");
printf(buffer);

AFTER:
sprintf(buffer, "weird example");
printf(buffer);

What was removed was:

-You're
-and
-this
-is
-an

I have looked into the token string manipulative and that only removes certain characters, not words.

Also, if its easier, Im just in need of removing about 50 characters/words at the beginning and after of the string. Later I will need to substitute a series of characters as someting else, but I can make a strcpy and if they match, replace it with what I need. Please help, or atleast point me to a place that has EVERYTHING about strings and how to change/manipulate them. I know Im asking somewhat alot, but itd really help if i got an answer or some explanation of what to do. Thanks.


strtok to the next word (ie char after a space), store the position of this char
strtok to the next word (ie char after a space), store this position too.
compare the chars between these two with each word of the same length in your 'compare' list.
sprintf/memcpy the first chunk (0-char1)(ie. OK words) to another buffer.
repeat till end of string.

There might be libraries that can do this though:p
have you tried looking at <string.h>, if it's been built for the PSP?
str
Back to top
View user's profile Send private message
sg57



Joined: 14 Oct 2005
Posts: 154

PostPosted: Wed Mar 08, 2006 1:23 am    Post subject: Reply with quote

I have looked in all of the libraries. So far I have gotten from an 'expert' at go4g.com that I have to parse the string then simply make a string compare call and if < matches >, then remove the <amsdf> word. I still do not understand your postas to what to do, but Im re reading it......
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group