Thay thế khoảng trắng bằng %20 javascript

Có được những hiểu biết hữu ích và nâng cao kiến ​​thức phát triển web của bạn với các mẹo và hướng dẫn hàng tuần từ Coding Beauty. Hơn 1.400 nhà phát triển đăng ký

1. Phương thức thay thế chuỗi []

Để xóa tất cả khoảng trắng khỏi một chuỗi trong JavaScript, hãy gọi phương thức

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
61 trên chuỗi, chuyển một chuỗi chứa khoảng trắng làm đối số đầu tiên và một chuỗi trống [
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
62] làm đối số thứ hai. Ví dụ:
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
63 xóa tất cả khoảng trắng khỏi
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
64

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

Phương thức

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
0
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
61 trả về một chuỗi mới với tất cả các kết quả khớp của một mẫu được thay thế bằng một chuỗi thay thế. Đối số đầu tiên là mẫu để khớp và đối số thứ hai là thay thế. Vì vậy, việc chuyển chuỗi trống làm đối số thứ hai sẽ thay thế tất cả các khoảng trắng bằng không có gì, điều này sẽ loại bỏ chúng

Ghi chú

Các chuỗi trong JavaScript là bất biến và

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
61 trả về một chuỗi mới mà không sửa đổi chuỗi gốc

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C

2. Phương thức thay thế chuỗi [] với Regex

Ngoài ra, chúng ta có thể xóa tất cả các khoảng trắng khỏi một chuỗi bằng cách gọi phương thức

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
3 trên chuỗi, chuyển một biểu thức chính quy khớp với bất kỳ khoảng trắng nào làm đối số đầu tiên và một chuỗi trống [
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
62] làm đối số thứ hai

const str = 'A B C';
const allSpacesRemoved = str.replace[/ /g, ''];

console.log[allSpacesRemoved]; // ABC

Chúng tôi sử dụng cờ regex

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
5 để chỉ định rằng tất cả các khoảng trắng trong chuỗi phải khớp với nhau. Nếu không có cờ này, chỉ khoảng trắng đầu tiên sẽ được khớp và thay thế

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C

Phương thức

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
0
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
3 trả về một chuỗi mới với tất cả các kết quả khớp được thay thế bằng đối số thứ hai được truyền cho nó. Chúng tôi chuyển một chuỗi trống làm đối số thứ hai để thay thế tất cả các khoảng trắng bằng không có gì, điều này sẽ loại bỏ chúng

Ghi chú

Như với

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
61,
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
3 trả về một chuỗi mới mà không sửa đổi chuỗi gốc

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
0

Mẹo

Biểu thức chính quy mà chúng tôi đã chỉ định chỉ khớp với khoảng trắng trong chuỗi. Để khớp và xóa tất cả các ký tự khoảng trắng [dấu cách, tab và dòng mới], chúng tôi sẽ phải sử dụng một biểu thức chính quy khác

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
1

Ayibatari Ibaba

Ayibatari Ibaba là nhà phát triển phần mềm có nhiều năm kinh nghiệm xây dựng trang web và ứng dụng. Anh ấy đã viết rất nhiều về nhiều chủ đề lập trình và đã tạo ra hàng chục ứng dụng và thư viện mã nguồn mở

Một giải pháp đơn giản là tạo một chuỗi phụ trợ và sao chép từng ký tự một. Bất cứ khi nào gặp khoảng trống, hãy đặt% 20 vào vị trí của nó

Cách tiếp cận 1. sử dụng chuỗi. chức năng thay thế []

Dưới đây là việc thực hiện các phương pháp trên

C++




const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
69

________ 670 ________ 671 ________ 672

 

________ 673 ________ 674

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
29

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
29
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

_______121____6692

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____6694
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
695

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

Python3




const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
697

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
698
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
699____6700
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
701

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
703______6704
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
708
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
709
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
710
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27_______6712
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
700
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
715

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
700
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
720
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
701

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
700
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
700
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
729
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
700
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
731

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____6733____127
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
700
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
737

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
700
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
29

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
699
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
700
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
744

Javascript




const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
745

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
746

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
747
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
748

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
201
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
205

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27____1214

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____1218

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
220

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
221
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
29

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
748

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
224

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
225

Đầu ra

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
2

Độ phức tạp về thời gian. O[N2] trong đó N là độ dài của chuỗi. vì nó đang sử dụng phương thức thay thế bên trong vòng lặp for
Không gian phụ trợ. Ô[1].

Cách tiếp cận 2. Một giải pháp tốt hơn để thực hiện tại chỗ giả sử rằng chúng ta có thêm khoảng trống trong chuỗi đầu vào. Trước tiên, chúng tôi đếm số khoảng trắng trong chuỗi đầu vào. Sử dụng số đếm này, chúng ta có thể tìm thấy độ dài của chuỗi [hoặc kết quả] đã sửa đổi. Sau khi tính toán độ dài mới, chúng tôi điền vào chuỗi tại chỗ từ cuối.  

Dưới đây là việc thực hiện các phương pháp trên

C++




const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
226

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
227

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
228

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
229
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
231

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
232

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
233

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
234

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
699
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
238

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
241

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
244

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
247

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
250
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
254

 

_______121____1256

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
258
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
259
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
264
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
265

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
264
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
267

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____1271

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
274

 

_______121____1276

_______121____1278

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
281

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
694
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
284

 

_______121____1286

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
289

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____1291

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
293
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
294
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

 

_______121____1297

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27____128
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
202

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
206

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
209____125
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
215____1216
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
219
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
220
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
224
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
227

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
231

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
235

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____6694
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
244

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
246

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
252
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
253
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

 

_______121____1256

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
259

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27____128
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
264

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
266
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
268
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
269

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____6694
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
695

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

Java




const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
274

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
275
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
276

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

_______121____1279

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____1281

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
283
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
285
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
286
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

 

_______121____1289

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____1291

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
293

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
295

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
283
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237____1299
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
201

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
241

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
208
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
209
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
210
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
209
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
215
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
209
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
217

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
250
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
254

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
241

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
258
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
229____1230
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
231
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
265

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
267

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
271

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
246
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
247
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
276

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
278

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
281

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
694
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
258

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
286

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
263____1230
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
268

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
270
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
271
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
273

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
297

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
280
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
230
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
282
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
209
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
284

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
206

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
291____125
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
215
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
216
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

_______1223____66901____1230____66903

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
220
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

_______1223____66901____1247____66903

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
224
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

_______1223____66913____66914

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
231

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223____66924

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
694
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
258

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____66937

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6939
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
283
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
73
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6942

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6947
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6948
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6949

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
256

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____66953

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6958
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
209
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
217

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27____66962

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6966

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6967

Python3




const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6968

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6969
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
286
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6973

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6974

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6975

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
698
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6977

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____66980

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6982
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6984

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
708
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
712
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6989

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____66991

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6993______6704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6995
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____66999

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____67001____6704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
708
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7004
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6993
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7006
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
247

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____67009

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____67011

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7014
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6969
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7016

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
694
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7019
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
230

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____67022

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7024
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7001
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7019
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
230

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6982
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7032
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6989

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____67035

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7038
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
709
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
710
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7041
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7019
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
247
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7044
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7019
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
247
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
701

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7049
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
216
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____67053

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7056
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
709
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
710
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7041
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7019
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
230
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7062
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
209
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7062
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7019
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
230
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
701

 

_______122____67069

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7072____6704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7016

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7078
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
216

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7082
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7019
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
230
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7085
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
220

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7082
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7019
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
247
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7085
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
224

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7024
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7024
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7019
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6914

_______122____1231____67016

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7078
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7072

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7024
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7019
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
230

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
694
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7115

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7116

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7118
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7121
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7016

________ 121 ________ 67124 ________ 6704 ________ 66948

________ 121 ________ 67124 ________ 6704 ________ 67130

________ 121 ________ 6733 ________ 67133

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7134

C#




const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7135

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
70
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7137

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
275
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
276

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

_______121____1279

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____1281

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
283
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
231

 

_______121____1289

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____1291

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
293

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____67156

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
283
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237____1299
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
201

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
241

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7169

________ 122 ________ 126 ________ 67172

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
250
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
254

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
241

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
258
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7184
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
265

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
267

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
271

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7199

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67201

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67203

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
281

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
694
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
258

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
286

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
28
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
289

 

_______122____1237____67217

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
270
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
271
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
273

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
297

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27____128
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7229

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
206

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7236
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
215
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
216
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
219
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
220
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
224
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
227

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
231

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

_______1223____67262

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
223
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
694
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
258

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21____66937

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6939
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
283
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
73
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7280

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
237____66947
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6948
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7287

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
256

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____66953

 

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27____128
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7296

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
27____67298

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7302

đầu ra.  

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
2

Độ phức tạp về thời gian. O[n], trong đó n là độ dài thực của chuỗi.
Không gian phụ trợ. O[1], vì chương trình trên là một thuật toán tại chỗ.

Cách tiếp cận 3. Cắt chuỗi và gọi phương thức replaceAll[], để thay thế tất cả khoảng trống Unicode thành %20.  

Dưới đây là việc thực hiện các phương pháp trên

Java




const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7303

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
275
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
276

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6939
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
283
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
73
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6942

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67315

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7317____1253
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67322

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67324

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67327

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7329
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7330
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7062
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7333

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22

_______122____67336

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67338

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

Python3




const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7342

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7343

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7124____6704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6948

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7347

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7124____6704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7350

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7351

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7124
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
704
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7354
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
25
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7062
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
26

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7359

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
733
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7133

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7362

C#




const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7363

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
70
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7137

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
275
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
276

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6939
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
283
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
73
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7374

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67315

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7317____1253
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7383

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67322

_______122____67387

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7383

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67327

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7392____67393
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7062
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23____67333

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7383

_______122____67336

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
22____67401

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
21
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
20

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7405

Javascript




const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
745

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7408

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7315

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7413
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
270
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
6948
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
24

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407____67322

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7324

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7327

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7329____67393
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7062
const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
23____67333

 

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7336

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407
const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7432

const str = 'A B C';

// No 'g' flag in regex
const spacesRemoved = str.replace[/ /, ''];

// Only first space removed
console.log[spacesRemoved]; // AB C
7407

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
225

Đầu ra

const str = 'A B C';
const allSpacesRemoved = str.replaceAll[' ', ''];

console.log[allSpacesRemoved]; // ABC

// Original not modified
console.log[str]; // A B C
2

Độ phức tạp về thời gian. O[N] trong đó N là độ dài của chuỗi.
Không gian phụ trợ. Ô[1].

Bài viết này được đóng góp bởi Aarti_Rathi và Brahmani Sai. Nếu bạn thích GeeksforGeeks và muốn đóng góp, bạn cũng có thể viết một bài báo bằng cách sử dụng write. chuyên viên máy tính. org hoặc gửi bài viết của bạn tới review-team@geeksforgeeks. tổ chức. Xem bài viết của bạn xuất hiện trên trang chính của GeeksforGeeks và trợ giúp các Geeks khác

Chủ Đề