Firstly, I think your regex needs some correction. See what you have:
test.com(\/\??index_.*.php\??(.*)|\/\?(.*)|\/|)+(\s)*(?!.)
In the case when you use optional ? at the beginning of index... , the second option is already taken care of:
test.com(\/index_.*.php\??(.*)|\/\?(.*)|\/|)+(\s)*(?!.)
Now you probably want the first (.*) Resolved if it was literal before ? . Otherwise, you will comply with test.com/index_fb2.phpanystringhereandyouprobablydon'twantthat . Therefore, move the corresponding optional marker:
test.com(\/index_.*.php(\?(.*))?|\/\?(.*)|\/|)+(\s)*(?!.)
Now .* Consumes any character and as much as possible. In addition,. before php consumes any character. This means that you allow both test.com/index_fb2php and test.com/index_fb2.html?someparam=php . Let it be a letter . and only allow unsigned characters:
test.com(\/index_[^?]*\.php(\?(.*))?|\/\?(.*)|\/|)+(\s)*(?!.)
Now the first, second and third parameters can be collapsed into one if we also make the file name optional:
test.com(\/(index_[^?]*\.php)?(\?(.*))?|)+(\s)*(?!.)
Finally, + can be removed, since inside (.*) Inside you can already take care of all possible repetitions. Also (something|) matches (something)? :
test.com(\/(index_[^?]*\.php)?(\?(.*))?)?(\s)*(?!.)
Seeing your input examples, it looks like you really want to match.
Then answer your question. What (?!.) Depends on whether you use singleline mode or not. If you do, he claims that you have reached the end of the line. In this case, you can simply replace it with \Z , which always matches the end of the line. If you do not, then he claims that you have reached the end of the line. In this case, you can use $ , but you also need to use multi-line mode, so $ also matches the ends of the lines.
So, if you use singleline mode (which probably means that you only have one URL per line), use this:
test.com(\/(index_[^?]*\.php)?(\?(.*))?)?(\s)*\Z
If you are not using singleline mode (which probably means you can have multiple URLs in your own lines), you should also use multiline mode and this kind of anchor instead:
test.com(\/(index_[^?]*\.php)?(\?(.*))?)?(\s)*$