Finding a specific string in a list
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have the following list:
l="apple","orange","kiwi","APPLE","lemon"
How can I make a command so the capitalised word would be returned?
So in this case the output should be
"APPLE"
Surely one can do l[[4]]
but this is not what I am looking for, I want to have a command to search on a long list and return the capital words. Also note that in my case the whole word is in capital letter not only the first letter. Also assume that I don't know what would be the capital word, I just know that I have a list and somewhere in it there is a capitalised letter word, I need to find those.
list-manipulation
add a comment |Â
up vote
1
down vote
favorite
I have the following list:
l="apple","orange","kiwi","APPLE","lemon"
How can I make a command so the capitalised word would be returned?
So in this case the output should be
"APPLE"
Surely one can do l[[4]]
but this is not what I am looking for, I want to have a command to search on a long list and return the capital words. Also note that in my case the whole word is in capital letter not only the first letter. Also assume that I don't know what would be the capital word, I just know that I have a list and somewhere in it there is a capitalised letter word, I need to find those.
list-manipulation
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have the following list:
l="apple","orange","kiwi","APPLE","lemon"
How can I make a command so the capitalised word would be returned?
So in this case the output should be
"APPLE"
Surely one can do l[[4]]
but this is not what I am looking for, I want to have a command to search on a long list and return the capital words. Also note that in my case the whole word is in capital letter not only the first letter. Also assume that I don't know what would be the capital word, I just know that I have a list and somewhere in it there is a capitalised letter word, I need to find those.
list-manipulation
I have the following list:
l="apple","orange","kiwi","APPLE","lemon"
How can I make a command so the capitalised word would be returned?
So in this case the output should be
"APPLE"
Surely one can do l[[4]]
but this is not what I am looking for, I want to have a command to search on a long list and return the capital words. Also note that in my case the whole word is in capital letter not only the first letter. Also assume that I don't know what would be the capital word, I just know that I have a list and somewhere in it there is a capitalised letter word, I need to find those.
list-manipulation
list-manipulation
asked 36 mins ago
William
42827
42827
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
l = "apple", "orange", "kiwi", "APPLE", "lemon", "Lemon", "leMon";
Select[l, UpperCaseQ]
"APPLE"
Ah, I need to recalibrate my gedanken Mathematica; I didn't know that plainUpperCaseQ
will still work! :)
– J. M. is somewhat okay.♦
27 mins ago
@J.M. my gedanken mma would have tried#==ToUpperCase[#]&
:)
– kglr
21 mins ago
add a comment |Â
up vote
1
down vote
Try
Select[l, StringMatchQ[__?UpperCaseQ]]
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
l = "apple", "orange", "kiwi", "APPLE", "lemon", "Lemon", "leMon";
Select[l, UpperCaseQ]
"APPLE"
Ah, I need to recalibrate my gedanken Mathematica; I didn't know that plainUpperCaseQ
will still work! :)
– J. M. is somewhat okay.♦
27 mins ago
@J.M. my gedanken mma would have tried#==ToUpperCase[#]&
:)
– kglr
21 mins ago
add a comment |Â
up vote
2
down vote
accepted
l = "apple", "orange", "kiwi", "APPLE", "lemon", "Lemon", "leMon";
Select[l, UpperCaseQ]
"APPLE"
Ah, I need to recalibrate my gedanken Mathematica; I didn't know that plainUpperCaseQ
will still work! :)
– J. M. is somewhat okay.♦
27 mins ago
@J.M. my gedanken mma would have tried#==ToUpperCase[#]&
:)
– kglr
21 mins ago
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
l = "apple", "orange", "kiwi", "APPLE", "lemon", "Lemon", "leMon";
Select[l, UpperCaseQ]
"APPLE"
l = "apple", "orange", "kiwi", "APPLE", "lemon", "Lemon", "leMon";
Select[l, UpperCaseQ]
"APPLE"
answered 31 mins ago
kglr
164k8188388
164k8188388
Ah, I need to recalibrate my gedanken Mathematica; I didn't know that plainUpperCaseQ
will still work! :)
– J. M. is somewhat okay.♦
27 mins ago
@J.M. my gedanken mma would have tried#==ToUpperCase[#]&
:)
– kglr
21 mins ago
add a comment |Â
Ah, I need to recalibrate my gedanken Mathematica; I didn't know that plainUpperCaseQ
will still work! :)
– J. M. is somewhat okay.♦
27 mins ago
@J.M. my gedanken mma would have tried#==ToUpperCase[#]&
:)
– kglr
21 mins ago
Ah, I need to recalibrate my gedanken Mathematica; I didn't know that plain
UpperCaseQ
will still work! :)– J. M. is somewhat okay.♦
27 mins ago
Ah, I need to recalibrate my gedanken Mathematica; I didn't know that plain
UpperCaseQ
will still work! :)– J. M. is somewhat okay.♦
27 mins ago
@J.M. my gedanken mma would have tried
#==ToUpperCase[#]&
:)– kglr
21 mins ago
@J.M. my gedanken mma would have tried
#==ToUpperCase[#]&
:)– kglr
21 mins ago
add a comment |Â
up vote
1
down vote
Try
Select[l, StringMatchQ[__?UpperCaseQ]]
add a comment |Â
up vote
1
down vote
Try
Select[l, StringMatchQ[__?UpperCaseQ]]
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Try
Select[l, StringMatchQ[__?UpperCaseQ]]
Try
Select[l, StringMatchQ[__?UpperCaseQ]]
answered 28 mins ago
community wiki
J. M. is somewhat okay.
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183678%2ffinding-a-specific-string-in-a-list%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password