I need to check for the last 4 characters in a list of words and if they are any of the following:
ac1
ac2
ac3
ac4
...and so on
then I need to say "ac found"
list = "forgottenac1","tomorrowac7","wallac1"
Is there some way to do this?
These forums are CLOSED. Please visit the new forums HERE
Finding the last 4 characters in a word |
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
05-06-2006 15:42
I need to check for the last 4 characters in a list of words and if they are any of the following:
ac1 ac2 ac3 ac4 ...and so on then I need to say "ac found" list = "forgottenac1","tomorrowac7","wallac1" Is there some way to do this? |
|
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
|
05-06-2006 16:10
Try something like...
llGetSubString(YourString, llStringLength(YourString)-4, -1); But in the example you give, ac1, ac2, ect... Looks like the last 3 characters of the string to me, so I'd change the -4 in the line above to -3... _____________________
![]() PICS - BLOG - http://arcticgreenhouse.blogspot.com/ XSTREET - INWORLD -http://slurl.com/secondlife/Alternate Reality/144/138/54/ |
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
05-06-2006 16:23
just FYI
llStringLength(YourString)-4 wont work quite rite you need a space between - and the number so it will subtract -4 = (negitive) 4 - 4 = (minus) 4 |
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
05-06-2006 16:40
CODE
this presumes you're looking just for commands that end with ac1-ac9, because it's what the description sounds like... if you want to check for things like ac1-ac99 then it gets more tricky since you can no longer rely on fixed spots to extract substrings from, and stuff. |
|
Starax Statosky
Unregistered User
Join date: 23 Dec 2003
Posts: 1,099
|
05-06-2006 16:42
I'm geekiest bastard here. Ner Ner!!
There's no need to get the string length: LastFour=llGetSubString(Word,-4,-1) Using negative values causes the function to count backwards from the end of the source string. Don't listen to the other two guys. They've obviously been having sexual intercourse or something and lost their geeky edge. |
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
05-06-2006 17:55
lol
|
|
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
|
05-06-2006 18:07
Don't listen to the other two guys. They've obviously been having sexual intercourse or something and lost their geeky edge. Close, I sprained my geeky edge last week, but during a virtual boating accident. Don't be putting crazy notions into peoples heads about me having a sex life outside of SL, thats just plain nonsense... ![]() _____________________
![]() PICS - BLOG - http://arcticgreenhouse.blogspot.com/ XSTREET - INWORLD -http://slurl.com/secondlife/Alternate Reality/144/138/54/ |
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
05-06-2006 18:19
this presumes you're looking just for commands that end with ac1-ac9, because it's what the description sounds like... if you want to check for things like ac1-ac99 then it gets more tricky since you can no longer rely on fixed spots to extract substrings from, and stuff. _____________________
-Seifert Surface
2G!tGLf 2nLt9cG |
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
05-06-2006 18:36
Change the naming scheme to ac01, ac02, ... ac99. Aye, if you don't mind dumping the extra work on the user then it's the best option. I just like to keep the stuff friendly to end receiver who will have to put up with it, i guess ^^; |
|
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
|
05-07-2006 13:15
Aye, if you don't mind dumping the extra work on the user then it's the best option. I just like to keep the stuff friendly to end receiver who will have to put up with it, i guess ^^; You could use llGetSubString to grab the last 2 characters, and then if the first one of those characters is a "c" you know your number is 1-9, and we want only the last character of the string. Otherwise if the 2nd to last character is not c and is a number, it's 10-99 so we want the last 2 characters... _____________________
![]() PICS - BLOG - http://arcticgreenhouse.blogspot.com/ XSTREET - INWORLD -http://slurl.com/secondlife/Alternate Reality/144/138/54/ |
|
Merlin Alphabeta
Registered User
Join date: 12 Feb 2006
Posts: 83
|
05-11-2006 09:54
Or, you know, he could go for the simple fix and just name them ac01, ac02, ... ac99
I know I know... blasphemy.... doing something the easy way! |