|
Rtoo Beginner
Joined: 30 Jul 2009 Posts: 11
|
Posted: Thu Jul 30, 2009 7:04 pm
Captured Varible with Multiple words, expanding them separately |
I am trying to get text I captured into a varible that has mulitiple words to expand into seperate words.
Example: @mobname = A grey fox
I want to make an alias that will do:
where A
where grey
where fox
Ultimately it would not do a where for a, the, etc. I can live with that if I can get the rest to work though. |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Thu Jul 30, 2009 8:04 pm |
You want to take a look at %replace, #forall and #if because you need to replace the spaces in the string with bars which allows you to loop through each item with #forall and while you have each item do a check with #if and ignore it if it's an A or the. You might want to do a %lower to the string first of all as that makes it easier doing the word checking with #if.
EDIT: Oh and you could keep the unwanted words in a string list variable and use a %ismember to do the unwanted word checking in one #if statement. |
|
_________________ Taz :) |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4715 Location: Pensacola, FL, USA
|
Posted: Thu Jul 30, 2009 11:46 pm |
#FORALL "a|an|the|etc" {mobname=%trim(%replace(%lower(@mobname), %i))}
#LOOP %numwords(@mobname) {where %word(@mobname, %i)} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Rtoo Beginner
Joined: 30 Jul 2009 Posts: 11
|
Posted: Fri Jul 31, 2009 4:01 pm |
This works pretty well, but if the mob name has an a|an|the, etc in it, it is being stripped also.
So the reaper is coming out as...
where reper
Thanks though, still much better than I had! |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Jul 31, 2009 5:00 pm |
Try this
#FORALL "a|an|the|etc" {mobname=%trim(%subregex(%lower(@mobname), %concat("\b",%i,"\b")))} |
|
_________________ Asati di tempari! |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Jul 31, 2009 11:24 pm |
It might be simpler just to do:
mobname=%trim(%subregex(%lower(@mobname),"\b(a|an|the|whatever)\b"))
which avoids the loop and multiple regex compiles. |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Mon Aug 03, 2009 4:27 pm |
You'd have to loop somewhere though otherwise you'd have just grey fox rather than grey and then fox.
|
|
_________________ Taz :) |
|
|
|
|
|