![]() |
Reg Expression to Exclude the contents of a Single folder
How can I exclude the contents of a folder using regular expressions.
Here is the code of the appspot app.yaml code. Code:
handlers:Please suggest a regexpression to exclude the contents of a single named folder. Thank you. |
In other words Here is the directory list
What will be the regex for all files and folders including those in the webroot but except the contents of subdir_a Please suggest. |
Try
Code:
url: .*(?!subdir_a) |
Is this code Java? This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia! Ask a mod to move this thread to the right forum.
|
Quote:
|
@Mayancode
Sorry, mis-information deleted! |
@julien that is not working and you are right since it is not javascript regex.
@Phillip Thanks, I am aware of the old saying "as car is to carpet, java is to javascript". I just could not find a forum matching its language... @Andy You are right, this is a python server configuration file... I was wrong in thinking the regex would be similar to javascript.. I have found the documentation here http://docs.python.org/2/library/re.html but I am still not able to make out a code which will let the errors arising in a specific folder to be handled by error_hander... All I want the code to be is to exclude folder /Codebox and its contents in the expressions used in the top part of the code which are handled by handlers |
Code:
- url: /dir_2/subdir_aCode:
- url: /dir_2/subdir_a/.*Code:
error_handlers:But this is the extent of my understanding.. and I may be wrong :) Added If you are looking to exclude a folder then 007julien has provided an example using a negative lookahead assertion. That is to say, "does not have this text". I do not know either, whether such a construct is acceptable within your configuration file. |
@Andy the script you suggested would work if I were having a python script (ex: errorhandling.py ) But I am not having any knowledge of python and so I would give up to adopt any alternative.
If only I could make sure non of the regex in the handlers referred to the particular folder /Codebox then I could assign error_handlers: as suggested here https://developers.google.com/appeng...rror_Responses |
What do you want it to do when someone visits /Codebox ?
|
If someone goes to
/Codebox/xyz.html then it should show them the page but ANY other address combination inside the Codebox directory such as /Codebox/superman.html should take him to a predefined 404.html page in located in the root directory. Do you think it is possible in the configuration file ? |
Until you find a proper solution you could perhaps add this code to your default 404 page so that it redirects to your alternative 404:
Code:
if (document.referrer.indexOf('Codebox') + 1) { |
:( I dont have the default 404page with me either... the 404 error is just a system generated cluttered python data ! I dont know editing the
main.py file either... :( May be we should consider for an alternative... |
Quote:
I wouldn't know if main.py is a general page over which you have no control, or whether you are allowed to create or modify your own version of this (it may not even exist!?). If you are able to track down your copy of this file (on your server's domain somewhere I assume) then I could have a gander at it. But I suspect that creating your own 404 page is the way to go. [I thought "lookahead negative assertion" was quite witty, in a reciprocal way?! Maybe its just me :) ] |
Here is the code of main.py
and it sits in the root and is editable very well.. Please take a look, I am sure this is the key to our solution... the filestructure is The main.py code Code:
import os |
| All times are GMT +1. The time now is 03:41 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.