|
yorcadon Beginner
Joined: 11 Jun 2009 Posts: 16
|
Posted: Fri Sep 03, 2010 5:53 pm
Comparing individual characters in variables and string lists! |
I need to compare single characters from a variable against single characters in a string list to see if they match.
For example if I have a variable set to "abc" and a string list, the first entry of which is "bcd" can I compare them and see if the first letter in the variable (being 'a') is the same as the first letter of the first entry in the string list (being 'b'). Also is the first letter in the variable equal to the second letter of the first entry in the string list, and so on.
Ideally I want to just use a #FORALL to compare the variable to every entry in the string list.
I know my way around cmud fairly well, just a kick in the right direction or a suggestion or anything would be great. Thanks |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Fri Sep 03, 2010 6:06 pm |
1)some combination of %left(), %right(), %leftback(), and %rightback() to pull out the desired substring
2)%begins() to test against the beginning of a string
3)see #1 for testing against 2nd/etc letter of each element in the stringlist |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Martaigne Wanderer
Joined: 05 Jan 2002 Posts: 88 Location: Atlanta, GA
|
Posted: Fri Sep 03, 2010 6:27 pm |
Also don't forget about %copy().
|
|
|
|
yorcadon Beginner
Joined: 11 Jun 2009 Posts: 16
|
Posted: Fri Sep 03, 2010 6:27 pm |
That should work. Seems a bit sloppy combining %right and %left to reach the middle letter, but should work anyways.
Thanks!
Edit: %copy works perfectly. Thank you. |
|
|
|
|
|