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...
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityYou can use DeleteCases
, Cases
, Select
, etc. Here a couple of examples:
DeleteCases[lis, s_?StringQ /; StringMatchQ[s, DigitCharacter..~~"-"~~DigitCharacter..]]
Select[lis, !StringMatchQ[#, DigitCharacter..~~"-"~~DigitCharacter..]&]