Please provide
- Operating system: Linux/PHPStorm
- SonarLint plugin version: 7.3.0.59206
- Programming language you’re coding in: PHP
- Is connected mode used: No
The rule suggests replacing preg_replace
with str_replace
. But that’s not always possible.
preg_replace('/_/', '/', 'some_string_with_many_underlines', 1);
// some/string_with_many_underlines
str_replace('_', '/', 'some_string_with_many_underlines');
// some/string/with/many/underlines
the fourth param of preg_replace
is $limit
. In the example above I want to replace just the first underline and not all of them.