in partnership with mediatemple

Ticket #646 (new defect)

Opened 6 months ago

Last modified 2 days ago

String.clean

Reported by: JanK Owned by: kamicane
Type: defect Priority: minor
Milestone: Mootools version 1.3 Component: Core
Keywords: Cc:

Description

String.clean replaces tabs and newlines with a space, but only if theres more than one consecutive whitespace, better would be to replace all whitespace by one space.

"foo\t\tbar".clean(); // "foo bar"
"foo\tbar".clean(); // "foo\tbar"

The regexp /\s+/g could replace the current regexp.

Change History

Changed 4 months ago by kamicane

  • status changed from new to closed
  • resolution set to fixed

fixed in [1342]

Changed 4 months ago by daniel@…

  • priority changed from trivial to critical
  • status changed from closed to reopened
  • resolution deleted

It looks like IE has some serious problems with /s regex. IE ignores nbsp; and that is really strange, because another, a bit more descriptive notation, works well.

Test page:
http://daniel.steigerwald.cz/strangewhitespaceregex/

Please compare results in Firefox and Internet Explorer 7

I suggest to use this: [ \f\n\r\t\v\u00A0\u2028\u2029]+/g

Changed 4 months ago by anonymous

ECMAScript (PDF, see 1 5 .10.2.10) specifies \s as [\t\n\v\f\r], Firefox added [\u00A0\u2028\u2029] to the list if the docs are complete.

Opera happens to match   with \s like Firefox. Safari behaves like the IE and doesnt match &nbsp with \s.

I didnt test \u2028 and \u2029, but I think /[\s\u00A0\u2028\u2029]+/g should fix this for all browsers, as it adds firefox`s additions to \s.

Changed 4 months ago by JanK

that was me, JanK

Changed 4 months ago by tomocchino

  • owner set to kamicane
  • status changed from reopened to new

Changed 3 months ago by anonymous

Changed 3 months ago by DanielSteigerwald

that was me, Daniel Steigerwald

Changed 3 months ago by kamicane

  • priority changed from critical to trivial

Changed 3 months ago by kamicane

  • milestone changed from Mootools version 1.2 to Mootools version 1.3

Changed 2 days ago by tomocchino

  • priority changed from trivial to minor
  • milestone set to Mootools version 1.3
Note: See TracTickets for help on using tickets.