asdasd

Benchmark created on


Setup

const text = 'w gerg esr esb '

const removeUnicodeControlChars1 = (text) => {
        if (!text) {
            return text;
        }
        
        // Unicode control characters to remove
        const controlChars = [
            '\u202A', // LRE (Left-to-Right Embedding)
            '\u202B', // RLE (Right-to-Left Embedding)
            '\u202C', // PDF (Pop Directional Formatting)
            '\u200E', // LRM (Left-to-Right Mark)
            '\u200F', // RLM (Right-to-Left Mark)
            '\u202D', // LRO (Left-to-Right Override)
            '\u202E', // RLO (Right-to-Left Override)
        ];

        let sanitized = text;
        controlChars.forEach(char => {
            sanitized = sanitized.replace(new RegExp(char, 'g'), '');
        });

        return sanitized;
    }
const removeUnicodeControlChars2 = (text) => {
  if (!text) {
    return text;
  }
  return text.replace(/[\u202A\u202B\u202C\u202D\u202E\u200E\u200F]/g, '');
}

Test runner

Ready to run.

Testing in
TestOps/sec
O(7n)
removeUnicodeControlChars1(text)
ready
O(n)
removeUnicodeControlChars2(text)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.