# String-manipulation bugs in v10.1

Introduced in 10.1, fixed in 10.2; fixed via paclet update in 10.1.

The new version 10.1 has introduced some strange (possibly buggy) behaviour compared to v10.0:

StringCases["1472", Except["0", DigitCharacter]]

(* v10.0 *) {"1","4","7","2"}
(* v10.1 *) {"1"}


Since StringCases["1472", DigitCharacter] returns {"1","4","7","2"} (all the characters) I would expect the same for an Except[char] pattern.

StringCases["1472", Except["0", DigitCharacter] ~~ "0" ... ~~ EndOfString]

(* v10.0 *) {"2"}
(* v10.1 *) {}


Further examples (thanks to Michael Hale):

StringReplace["1a2b3c4", Except["a", LetterCharacter] .. -> ""] (* ==> "1a2b3c4" *)


though even the documentation of Except says it should be: "1a234" (this should be the correct output).

StringCases["104702", Except["0", DigitCharacter]] (* ==> {"1", "4", "2"} *)


Furthermore, ToTitleCase removes all non-alphanumeric characters (except whitespace):

ToTitleCase["abcd,<>/-_=+~!@#\$%&*(){}[];': end...?"] (* ==> "Abcd End" *)


which is probably unwanted and is definitely undocumented.

(Filed it to TechSupport, will report back if they say anything.)

2015-07-29: ToTitleCase is not available anymore in version 10.2 (it was experimental).

• We needed a 10.0.3 with more bug fixes, not a 10.1 with new bugs! >:-@ – Mr.Wizard Apr 2 '15 at 14:31
• StringPatternPatternConvert[Except["0", DigitCharacter]] gives a different result in 10.1.0. This is the place to look to find out why it happens. I don't have time to look up all the various bits needed to understand what the actual regexes do ... – Szabolcs Apr 2 '15 at 14:33
• @Szabolcs In 10.1.0 we upgraded the PCRE library used for much of the string pattern matching. This must have slipped through. Reported internally. – Stefan R Apr 2 '15 at 16:19
• @Daniel (1) I sincerely apologize for any connotation of devaluing the work of you and your colleagues. Nevertheless it seems to me that from the top down there is a misplaced emphasis on new features over making existing ones work properly (fast and bug-free). 10.0.2 still feels a lot like a beta release; a 10.0.3 with the 10.1.0 bug fixes would be highly appreciated but I don't expect it will happen. If I can get that message across to Dr. Wolfram then my comment will have served its purpose. And I'll point out that my comment is attracting quite a few votes of agreement. – Mr.Wizard Apr 3 '15 at 18:41
• @Daniel (2) Perhaps some day the directorial emphasis will change and the copious talents of you and your team will be brought to bear on aspects of the product that are more important to me, and as I perceive many like me. – Mr.Wizard Apr 3 '15 at 18:43

This is a bug in version 10.1.0. We decided it was serious enough to warrant a fix via an automatic paclet update. The paclet has been pushed live and Mathematica should install it automatically once it does a periodic check with the paclet server. It should take about a week or so.

To install it right away, you can do PacletInstall["StringPatternFix"]. You may need to restart the kernel for the fix to take effect, but after that it should work in all subsequent kernel sessions automatically.

• I get this when I try it. Perhaps it just takes a bit longer? – Szabolcs Apr 6 '15 at 23:00
• @Szabolcs Hmm... Does doing PacletSiteUpdate /@ PacletSites[] help? – Stefan R Apr 7 '15 at 15:11
• It worked today, without PacletSiteUpdate. – Szabolcs Apr 7 '15 at 15:18
• Works now. :) Thank you! – Jinxed Apr 7 '15 at 17:44
• @Szabolcs It was deliberately removed. This is what our lead FE developer had to say about it: "[Why did I remove it]: Because it's an antiquity that is almost completely useless (and for those for whom it's not useless, I left the key binding). Question...why is interrupting useful? (a) If you wanted to abort, you'd just abort. (b) If you want to continue, then why did you interrupt in the first place? (c) If you wanted to check status, you could use any number of modern features, including Evaluate in Subsession, Monitor, PrintTemporary, etc. " – Stefan R Apr 10 '15 at 20:21

Workaround for the two-argument Except in string patterns issue until it is fixed:

StringCases["104702", DigitCharacter?(! StringMatchQ[#, "0"] &)]


Match the second argument directly, then use PatternTest` to check that it also doesn't match the first argument.