Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.7K Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

[?] Simple rewrite rule using String function works but shows error?

Posted 8 years ago

I used Matlab/Mathematica during my PhD in 1993 and now trying to learn the fascinating Wolfram Language. So this might be a newby question so bear with me. The below simple expression

{"a.del", "b.del", "c.del"} /. s__ -> StringDelete[s, ".del"]

generates the expectecd content

{"a", "b", "c"}

but generates also the following error

StringDelete::strse: String or list of strings expected at position 1 in StringDelete[s,.del].

What am I doing wrong? Thanks for your help. Regards Markus

3 Replies

Notice that these also work:

In[1]:= StringDelete[".del"] /@ {"a.del","b.del","c.del"}
Out[1]= {a,b,c}

In[2]:= StringDelete[".del"][{"a.del","b.del","c.del"}]
Out[2]= {a,b,c}

In[3]:= StringDelete[{"a.del","b.del","c.del"},".del"]
Out[3]= {a,b,c}
POSTED BY: Gustavo Delfino
Posted 8 years ago
POSTED BY: Hans Milton
POSTED BY: Todd Rowland
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard