replace regex vs replace All vs replace regex with String.rawFastest: replace regex (5.1x faster)
4,178,460 ops/sec
3,599,163 ops/sec
816,925 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| replace regex | |
| replace All | |
| replace regex with String.raw |
| Test name | Executions per second |
|---|---|
| ✓ replace regex | 3,738,517 Ops/sec |
| replace All | 3,210,140 Ops/sec |
| replace regex with String.raw | 637,969 Ops/sec |