Mathematica 9 is now available
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: [mg121521] Re: String Deletion
  • From: "Dr. Wolfgang Hintze" <weh at snafu.de>
  • Date: Sun, 18 Sep 2011 04:12:12 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j51sst$pfv$1@smc.vnet.net>

"Don" <donabc at comcast.net> schrieb im Newsbeitrag 
news:j51sst$pfv$1 at smc.vnet.net...
> 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.
>
What about the following two solutions?

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

Complement[list, Select[list, StringPosition[#, ":"] != {} &]]
{aye}

Complement[list, Flatten[StringCases [#, _ ~~ ":" ~~ __] & /@ list]]
{aye}

Best regards,
Wolfgang 





  • Prev by Date: Re: CUDA computing
  • Next by Date: Re: output forms
  • Previous by thread: Re: String Deletion
  • Next by thread: Re: String Deletion