I'm not familiar with the how regular expressions treat hexadecimal, anyone knows?
php
regex
hex
Answers
2
You should use an array of "disallowed" terms and use strpos
and str_replace
to dynamically remove them from the passed-in URL:
function remove_http($url) {
$disallowed = array('http://', 'https://');
foreach($disallowed as $d) {
if(strpos($url, $d) === 0) {
return str_replace($d, '', $url);
}
}
return $url;
}
Thursday, August 25, 2022
5
The Arabic regex is:
[u0600-u06FF]
Actually, ?-?
is a subset of this Arabic range, so I think you can remove them from the pattern.
So, in JS it will be
/^[a-z0-9+,()/'su0600-u06FF-]+$/i
See regex demo
Tuesday, October 11, 2022
3
Use a loop like so
$data = file('website/files/myfolder/file.html');
for ($i = 23; $i <= 116; $i++) {
echo $data[$i];
}
- http://php.net/manual/en/control-structures.for.php
Or you could splice the data:
$data = file('website/files/myfolder/file.html');
echo implode(PHP_EOL, array_splice($data, 23, 116 - 23));
- http://php.net/manual/en/function.array-splice.php
- http://php.net/manual/en/function.implode.php
Friday, September 23, 2022
3
For this PHP regex:
$str = preg_replace ( '{(.)1+}', '$1', $str );
$str = preg_replace ( '{[ '-_()]}', '', $str )
In Java:
str = str.replaceAll("(.)\1+", "$1");
str = str.replaceAll("[ '-_\(\)]", "");
I suggest you to provide your input and expected output then you will get better answers on how it can be done in PHP and/or Java.
Sunday, October 9, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
php
regex
hex
The following does the trick:
The important thing is the
u
-modifier (see here):And here a short description why
uFFFF
is not working in PHP: