Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5048

Re: String Deletion

From "Dr. Wolfgang Hintze" <weh@snafu.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: String Deletion
Date 2011-09-18 08:20 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j549jj$6de$1@smc.vnet.net> (permalink)
References <j51sst$pfv$1@smc.vnet.net>

Show all headers | View raw


"Don" <donabc@comcast.net> schrieb im Newsbeitrag 
news:j51sst$pfv$1@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 

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

String Deletion Don <donabc@comcast.net> - 2011-09-17 10:30 +0000
  Re: String Deletion "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-09-18 08:12 +0000
  Re: String Deletion David Bailey <dave@removedbailey.co.uk> - 2011-09-18 08:10 +0000
  Re: String Deletion "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-09-18 08:20 +0000
  Re: String Deletion Tyler <hayes.tyler@gmail.com> - 2011-09-18 08:25 +0000
    Re: String Deletion Tyler <hayes.tyler@gmail.com> - 2011-09-19 11:13 +0000

csiph-web