MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: String Deletion

  • To: mathgroup at
  • Subject: [mg121503] Re: String Deletion
  • From: David Bailey <dave at>
  • Date: Sun, 18 Sep 2011 04:08:56 -0400 (EDT)
  • Delivered-to:
  • References: <j51sst$pfv$>

On 17/09/2011 11:30, Don wrote:
> Given a simple list of strings:
> list =  List["Z:XBREG","Z:XBREH","Z:XBREI","Z:ZZ6P","Z:ZZ6Q","aye"]
> how does one delete all the strings with a colon (:) anywhere in the string?
> DeleteCases[list, ___:___]  looks very logical  and should work,
> but of course it doesn't .
> Also, there is a StringCases function which would seem
> to correspond with the Cases function.  There is a
> DeleteCases function but no string counterpart, namely,
> DeleteString function.  Any reason for this?
> Thanks in advance.
The short answer (one of several possible) is:



The longer answer is to encourage you to learn the syntax of 
Mathematica! If you had, you would realise that the colon in 
DeleteCases[list, ___:___] appears in the context of an operator - it is 
not a character in a string, so that expression is not going to pick out 
strings containing a colon, any more than it is going to pick out 
strings containing "_", or "[", or "]".

Any computer language that allows character/string manipulation, has to 
distinguish between characters representing themselves, and characters 
that are part of the expression syntax.

StringCases operates on a string (although the first argument can be a 
list of strings, but that only applies StringCases to every item of the 

David Bailey

  • Prev by Date: Re: Interactive settings for ParamPlot3D. Mesh not quite working.
  • Next by Date: Re: output forms
  • Previous by thread: Re: String Deletion
  • Next by thread: Re: String Deletion