Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have a list:
lis = {"ab","a-1","1-20"}
from which I need to delete elements of lis that has (only) digits on both sides of the hyphen, in each element that contains a hyphen:
res = {"ab","a-1"}
Thanks In advance for any advice...
You can use DeleteCases, Cases, Select, etc. Here a couple of examples:
DeleteCases
Cases
Select
DeleteCases[lis, s_?StringQ /; StringMatchQ[s, DigitCharacter..~~"-"~~DigitCharacter..]] Select[lis, !StringMatchQ[#, DigitCharacter..~~"-"~~DigitCharacter..]&]
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.