| Server IP : 121.121.20.254 / Your IP : 216.73.216.202 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/KnowledgeBase/wp-content/plugins/aioseo-redirects/app/Utils/ |
Upload File : |
<?php
namespace AIOSEO\Plugin\Addon\Redirects\Utils;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Regex helpers.
*
* @since 1.2.1
*/
class Regex {
/**
* Returns a regex with ignore slash support.
*
* @since 1.2.1
*
* @param string $regex A regex string.
* @return string The regex with ignore slash support.
*/
public static function ignoreSlash( $regex ) {
// Slash at the end of the regex.
$regex = preg_replace( '@/$@', '(|/)', $regex, 1 );
// Slash at the end of the regex with an explicit $.
$regex = preg_replace( '@/\$$@', '(|/)$', $regex, 1 );
// Slash in the middle of the regex right before the start of a query arg.
$regex = preg_replace( '@/\?|(?<!\\\)\?@', '(|/)?', $regex, 1 );
return $regex;
}
}