regex replace vs string substring vs string sliceFastest: string slice (1.7x faster)
14,793 ops/sec
9,933 ops/sec
8,703 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| regex replace | |
| string substring | |
| string slice |
| Test name | Executions per second |
|---|---|
| ✓ string slice | 14,445 Ops/sec |
| string substring | 9,704 Ops/sec |
| regex replace | 8,405 Ops/sec |