Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: String Deletion

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121507] Re: String Deletion
  • From: "Oleksandr Rasputinov" <oleksandr_rasputinov at hmamail.com>
  • Date: Sun, 18 Sep 2011 04:09:40 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j51sst$pfv$1@smc.vnet.net>

On Sat, 17 Sep 2011 11:30:53 +0100, Don <donabc at comcast.net> 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.
>

___:___ is not a particularly meaningful pattern. Its FullForm makes this  
clear:

Optional[BlankNullSequence[],BlankNullSequence[]]

To achieve what you want, you could try something like the following:

In[1] :=
list = {"Z:XBREG", "Z:XBREH", "Z:XBREI", "Z:ZZ6P", "Z:ZZ6Q", "aye"};

In[2] :=
Select[list, StringFreeQ[#, ":"] &]

Out[2] =
{"aye"}




  • Prev by Date: 2 parameter bifurcation diagrams
  • Next by Date: Re: String Deletion
  • Previous by thread: Re: String Deletion
  • Next by thread: Re: String Deletion