|
JeanValjean Newbie
Joined: 23 Apr 2004 Posts: 8 Location: Denmark
|
Posted: Mon Apr 26, 2004 3:28 pm
A sort of complicated trigger |
I am looking to make a trigger that will add a lisp to my character, as a sort of personal trait.
What i am looking to do, is add a "-ss" to all words that have an S at either the beginning, or end of the word. Can this be done within reasonable coding?
JeanV |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Apr 26, 2004 6:56 pm |
No, not really. It's quite easy to replace all instances of "s" with "ss".
#AL lisp {%replace( "%-1", s, ss)}
However, limiting replacement to the first and last letters of the word requires using a loop structure to evaluate and modify every word. Aliases to do so have been attempted fairly often, you can probably find one using the Search link. |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Mon Apr 26, 2004 6:58 pm |
This would probably be easier with regular expressions, but I don't know how to do them.
This should work though:
#alias Lisp {#var LispString %null;#var String "%-1";#loop %numwords(%-1) {#if (((%begins(%word(@string,%i),"s")) AND ((!%ends(%word(@string,%i),",")) AND (!%ends(%word(@string,%i),".")))) OR (%ends(%word(@string,%i),"s"))) {#var LispString {%concat(@LispString,%word(@string,%i),"-ss")}} {#var LispString {%concat(@LispString,%word(@string,%i))}}}}
It doesn't put a -ss on words that begin/end with an s, and a comma or period, however. |
|
|
|
JeanValjean Newbie
Joined: 23 Apr 2004 Posts: 8 Location: Denmark
|
Posted: Mon Apr 26, 2004 9:17 pm |
The first one works fine for me, thanks Lightbulb. It wont work with capital letters though... Anything to do?
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Apr 27, 2004 1:32 am |
Just do a second replace for the capital letters. Be careful about the order if you use Ss rather than SS.
#AL lisp {%replace( %replace( "%-1", s, ss), S, Ss)} |
|
|
|
jessew Apprentice
Joined: 03 Mar 2003 Posts: 141
|
Posted: Tue Apr 27, 2004 2:46 am |
If you want to make sure its only the first or last letter heres a function that works.
#function lispmake {%if(%begins(%lower(%1),"s"),s)%1%if(%ends(%lower(%1),"s"),s)}
That will really only work for 1 word
like:
say @lisp("super") .. will return say ssuper
So You can then make a regex function if you want to send each word
in a sentence to that function.
#FUNCTION lisp {%subregex(%-1, "b(w+)b", "@lispmake(%%1)"}
say @lisp("Seven Sisters snicker ") ..gets sSeven sSisterss ssnicker
Cheers Jesse |
|
|
|
|
|
|
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
|
|