How can I catch lines that do not start with "ajax /" using regex for CodeIgniter?

I am working on some routes for my CodeIgniter application and I need to declare "catch-all" / with the exception of one regex. Any route that does not start with "ajax /" should be redirected to the "main" router. For instance:

$route['regexmagichere'] = "main";

So, this definitely goes beyond my regular expression skills, and I need help. The regular expression should return true for all lines that do not start with 'ajax /', for example:

$string_one = "ajax/someotherstuffhere";
$string_two = " ajax/test";
$string_three = "somestuffhere";

Here $ string_one will be the only one returning false. Thank you for your time!

+3
source share
3

^((?!ajax).*)
+6

. , true , ajax/:

^(?!ajax/).*

/ \/. (?!) - , .

+3

I think that ^(?<!ajax)\/will do the trick.

I emphasize "think"!

-1
source

Source: https://habr.com/ru/post/1756183/


All Articles