<?php
$string_original = "
Ivq6T2IoWbLNCoru7RTv
kcEDwTVDhkqRAePOOQsM
c6pcDsaq1waWzuzNHAYl
pqFRFt1XwSX6JBLslwDs
VWygeUir8kWMOpU5RArI
WZ1UCYybMhpetyaCCkiM
8OVqENVpWmCZvDyvq8dG
PPxPs48xPuiaLGdKhjEl
2i5y2URwQlRS1pbrKDS5
euT3KHvPrhM5wnOyTpJv
";
var_dump($string_original);
$string = $string_original;
$pattern = '%'
# Select a digit and 5 letters after
.'(\d)(\w{5})'
.'%';
$string = preg_replace_callback(
$pattern,
function($matches){
# Add to one to digit and then lowercase 5 letters after.
$matches[1] = $matches[1] + 1;
$matches[2] = strtolower($matches[2]);
return $matches[1].$matches[2];
},
$string);
var_dump($string);
$string = $string_original;
$pattern = '%'
# Any digit and after 5 alpha-numeric characters.
.'(\d)(?<=\w{5})'
.'%';
# Replace all integers to symbols
$string = preg_replace_callback(
$pattern,
function($matches){
if($matches[1] >= 5){
return '_';
}else{
return '@';
}
},
$string,
# Limit only 2 replacements
2);
var_dump($string);
# Array Replacement
$arr = [
'IUjd5x13NF1OyQn9Afjy',
'S1BG0EhuWxr5icrgD1St',
'oLKV7cI6Qx5503K0eJ6U',
'V36IgE0TE6Qq6beBnJkC',
'jcMIKR9wk9u8kdN6UyPR',
'N8CNqZDQPJwLH87rnmKq',
'yeSAo75DcWQqQM9FynIu',
'QoRWAnP2G1LGkRoBbiud',
'tiVkR9UkIiB6ChI6l6Se',
'9BWLYV7msRz7WsSADx7u'
];
$pattern = '%'
# Any Digit after 10 characters
.'(\d)(?<=\w{10})'
.'%';
# Replace integers from <5 to _ and >5 to @
# Note the limit here works per line in the array.
$arr = preg_replace_callback(
$pattern,
function($matches){
if($matches[1] >= 5){
return '_';
}else{
return '@';
}
},
$arr,
1,
4);
var_dump($arr);
- Output for 8.3.0 - 8.3.6
- string(211) "
Ivq6T2IoWbLNCoru7RTv
kcEDwTVDhkqRAePOOQsM
c6pcDsaq1waWzuzNHAYl
pqFRFt1XwSX6JBLslwDs
VWygeUir8kWMOpU5RArI
WZ1UCYybMhpetyaCCkiM
8OVqENVpWmCZvDyvq8dG
PPxPs48xPuiaLGdKhjEl
2i5y2URwQlRS1pbrKDS5
euT3KHvPrhM5wnOyTpJv
"
string(211) "
Ivq7t2iowbLNCoru7RTv
kcEDwTVDhkqRAePOOQsM
c7pcdsaq2wawzuzNHAYl
pqFRFt2xwsx6JBLslwDs
VWygeUir9kwmopU5RArI
WZ2ucyybMhpetyaCCkiM
9ovqenVpWmCZvDyvq8dG
PPxPs58xpuiaLGdKhjEl
3i5y2uRwQlRS2pbrkdS5
euT4khvprhM6wnoytpJv
"
string(211) "
Ivq6T@IoWbLNCoru_RTv
kcEDwTVDhkqRAePOOQsM
c6pcDsaq1waWzuzNHAYl
pqFRFt1XwSX6JBLslwDs
VWygeUir8kWMOpU5RArI
WZ1UCYybMhpetyaCCkiM
8OVqENVpWmCZvDyvq8dG
PPxPs48xPuiaLGdKhjEl
2i5y2URwQlRS1pbrKDS5
euT3KHvPrhM5wnOyTpJv
"
Fatal error: Uncaught Error: preg_replace_callback(): Argument #5 ($count) could not be passed by reference in /in/MfYVE:89
Stack trace:
#0 {main}
thrown in /in/MfYVE on line 89
Process exited with code 255. - Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18
- string(211) "
Ivq6T2IoWbLNCoru7RTv
kcEDwTVDhkqRAePOOQsM
c6pcDsaq1waWzuzNHAYl
pqFRFt1XwSX6JBLslwDs
VWygeUir8kWMOpU5RArI
WZ1UCYybMhpetyaCCkiM
8OVqENVpWmCZvDyvq8dG
PPxPs48xPuiaLGdKhjEl
2i5y2URwQlRS1pbrKDS5
euT3KHvPrhM5wnOyTpJv
"
string(211) "
Ivq7t2iowbLNCoru7RTv
kcEDwTVDhkqRAePOOQsM
c7pcdsaq2wawzuzNHAYl
pqFRFt2xwsx6JBLslwDs
VWygeUir9kwmopU5RArI
WZ2ucyybMhpetyaCCkiM
9ovqenVpWmCZvDyvq8dG
PPxPs58xpuiaLGdKhjEl
3i5y2uRwQlRS2pbrkdS5
euT4khvprhM6wnoytpJv
"
string(211) "
Ivq6T@IoWbLNCoru_RTv
kcEDwTVDhkqRAePOOQsM
c6pcDsaq1waWzuzNHAYl
pqFRFt1XwSX6JBLslwDs
VWygeUir8kWMOpU5RArI
WZ1UCYybMhpetyaCCkiM
8OVqENVpWmCZvDyvq8dG
PPxPs48xPuiaLGdKhjEl
2i5y2URwQlRS1pbrKDS5
euT3KHvPrhM5wnOyTpJv
"
Fatal error: Uncaught Error: preg_replace_callback(): Argument #5 ($count) cannot be passed by reference in /in/MfYVE:89
Stack trace:
#0 {main}
thrown in /in/MfYVE on line 89
Process exited with code 255. - Output for 7.1.25 - 7.1.28, 7.2.0 - 7.2.18, 7.3.0 - 7.3.5
- Fatal error: Only variables can be passed by reference in /in/MfYVE on line 89
Process exited with code 255.
preferences:
104.17 ms | 402 KiB | 56 Q