Forum Moderators: phranque

Message Too Old, No Replies

Excluding from regex match

         

ntbgl

10:55 pm on May 1, 2009 (gmt 0)

10+ Year Member



I have a form that allows users to name pages.

It use to be that page names on my site could not include a forward slash (/) in them. I used the following regex to block matching titles:

.*\/.*

However, now, users are able to have a forward slash if the title starts with "Title:". How can I rewrite my regex to only block matching titles that don't have Title: in front?

[^Title:].*\/.* ?

Thanks

jdMorgan

1:50 am on May 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It would have been helpful to see the code to give a more-specifically-formatted example, but hopefully, you can adapt this:

If string contains "/"
^[^/]*/
AND If string is NOT Title:<zero or more characters not matching a slash> followed by a slash
!^Title:[^/]*/
Then block

It is not necessary in mod_rewrite regex to escape slash characters.

Jim