|
Eyeless Wanderer
Joined: 02 Dec 2001 Posts: 80 Location: Canada
|
Posted: Thu Jan 29, 2004 5:20 am
Stripping unwanted words, punctuation |
#var loot %replace( "%1", ",", "|")
works great for commas, but how do I build it if I want to remove all punctuation and other certain words... for example: , ! . AND and.
also if I just want the right most word in each string item, is this possible as well? |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Jan 29, 2004 6:37 pm |
You can repeat the %replace as often as desired, changing any characters you don't want into characters which you do want. Among the things you can change to is a null string.
#VAR loot {%replace( "%1", ",", "|")}
#VAR loot {%replace({@loot}, "!", "")}
#VAR loot {%replace({@loot}, " and ", " ")} |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Jan 29, 2004 11:08 pm |
Also you might want to use %subchar. For example:
#VAR loot {%subchar("%1", "!.?:()[]<>", "")
This method is character based so it doesn't work for a phrase/word like "and", but can neatly eliminate all punctuation. |
|
|
|
Valint Wanderer
Joined: 12 Nov 2003 Posts: 70 Location: USA
|
Posted: Fri Jan 30, 2004 2:01 am |
> also if I just want the right most word in each string item, is this possible as well?
One way to do so would be this, though there are likely more elegant ways out there:
#LOOP %numitems( @loot) {#VAR loot %replaceitem( %word( %item( @loot, %i), %numwords( %item( @loot, %i))), %i, @loot)} |
|
|
|
Eyeless Wanderer
Joined: 02 Dec 2001 Posts: 80 Location: Canada
|
Posted: Fri Jan 30, 2004 3:24 am |
Thank you.
|
|
|
|
|
|
|
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
|
|