www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - replacement for squeeze and removechars.

reply Antonio Corbi <acb ggmail.com> writes:
Hi all,

I'm trying dmd-2.075.0-rc1 in one of my projects where I use 
`squeeze` and `removechars`. Both of them are flagged as obsolete 
and in the docs we are suggested to use functions from std.regex 
and/or std.algorithm.

Does any one kow a one-liner from std.regex or std.algorithm that 
can take the role of those deprecated functions?

Thank's
A. Corbi
Jul 18
next sibling parent Seb <seb wilzba.ch> writes:
On Tuesday, 18 July 2017 at 15:28:06 UTC, Antonio Corbi wrote:
 Hi all,

 I'm trying dmd-2.075.0-rc1 in one of my projects where I use 
 `squeeze` and `removechars`. Both of them are flagged as 
 obsolete and in the docs we are suggested to use functions from 
 std.regex and/or std.algorithm.

 Does any one kow a one-liner from std.regex or std.algorithm 
 that can take the role of those deprecated functions?

 Thank's
 A. Corbi
RTFM: https://dlang.org/changelog/2.075.0.html#pattern-deprecate
Jul 18
prev sibling parent reply Meta <jared771 gmail.com> writes:
On Tuesday, 18 July 2017 at 15:28:06 UTC, Antonio Corbi wrote:
 Hi all,

 I'm trying dmd-2.075.0-rc1 in one of my projects where I use 
 `squeeze` and `removechars`. Both of them are flagged as 
 obsolete and in the docs we are suggested to use functions from 
 std.regex and/or std.algorithm.

 Does any one kow a one-liner from std.regex or std.algorithm 
 that can take the role of those deprecated functions?

 Thank's
 A. Corbi
As Seb somewhat undiplomatically put, there are replacements listed in the changelog. Use std.regex.replaceAll to replace std.string.removechars: import std.string; import std.regex; // old "abc".removechars("a-z"); // new "abc".replaceAll(regex("[a-z]"), ""); Use std.algorithm.iteration.uniq to replace std.string.squeeze: import std.algorithm; import std.string; // old "hello".squeeze; // new "hello".uniq; Though it would be nice to have these alternatives listed right there in the deprecation message.
Jul 18
next sibling parent Antonio Corbi <acb ggmail.com> writes:
On Tuesday, 18 July 2017 at 15:41:44 UTC, Meta wrote:
 On Tuesday, 18 July 2017 at 15:28:06 UTC, Antonio Corbi wrote:
 Hi all,

 I'm trying dmd-2.075.0-rc1 in one of my projects where I use 
 `squeeze` and `removechars`. Both of them are flagged as 
 obsolete and in the docs we are suggested to use functions 
 from std.regex and/or std.algorithm.

 Does any one kow a one-liner from std.regex or std.algorithm 
 that can take the role of those deprecated functions?

 Thank's
 A. Corbi
As Seb somewhat undiplomatically put, there are replacements listed in the changelog. Use std.regex.replaceAll to replace std.string.removechars: import std.string; import std.regex; // old "abc".removechars("a-z"); // new "abc".replaceAll(regex("[a-z]"), ""); Use std.algorithm.iteration.uniq to replace std.string.squeeze: import std.algorithm; import std.string; // old "hello".squeeze; // new "hello".uniq; Though it would be nice to have these alternatives listed right there in the deprecation message.
Thanks Meta and Seb! Yes, the replacement is there 8), but as the deprecation message told me "to go to the docs", I only had in mind the library manual pages and not the changelog. I agree with you that, at least, they could also be listed next to `squeeze` and `removechars`. Thanks for your help! A. Corbi
Jul 18
prev sibling parent reply Seb <seb wilzba.ch> writes:
On Tuesday, 18 July 2017 at 15:41:44 UTC, Meta wrote:
 As Seb somewhat undiplomatically put, there are replacements 
 listed in the changelog.
Sorry - it wasn't intended to be an offense or aggressive. I consider(ed) RTFM as common internet slang.
Jul 18
next sibling parent Antonio Corbi <acb ggmail.com> writes:
On Tuesday, 18 July 2017 at 15:55:00 UTC, Seb wrote:
 On Tuesday, 18 July 2017 at 15:41:44 UTC, Meta wrote:
 As Seb somewhat undiplomatically put, there are replacements 
 listed in the changelog.
Sorry - it wasn't intended to be an offense or aggressive. I consider(ed) RTFM as common internet slang.
Dont' worry Seb, I really appreciate very much your help. A. Corbi
Jul 18
prev sibling parent Jonathan M Davis via Digitalmars-d-learn writes:
On Tuesday, July 18, 2017 15:55:00 Seb via Digitalmars-d-learn wrote:
 On Tuesday, 18 July 2017 at 15:41:44 UTC, Meta wrote:
 As Seb somewhat undiplomatically put, there are replacements
 listed in the changelog.
Sorry - it wasn't intended to be an offense or aggressive. I consider(ed) RTFM as common internet slang.
It is, but you have to be careful with it. It could be "Read the Friendly Manual," or it could be "Read the F #%ing Manual," depending on the intent of the person writing it, and it's not always clear which the writer means. And it's used so frequently to indicate that someone should have known to read the manual that I expect that a lot of folks are going to take it the wrong way - especially if that's all you say. So, while it _can_ be used in a friendly manner, it's an acronym that I'd avoid. - Jonathan M Davis
Jul 18