2
votes

Adobe CQ5 dialog editor, regex property:

I am regex challenged so forgive me, but it seems a simple task and I just can't seem to find the right fit elsewhere on the internet. Every suggestion that looks right just doesn't seem to work in adobe's regex field.

I want the content admin to supply a relative URL to a "thank you" page. I don't need anything super fancy, I simply want to reject the admin's input if "http" or ".com" is found anywhere within the text supplied by the admin.

Examples for admin supplied input:
URL                                       REGEX VALIDATES INPUT AS SUCCESS?
http://www.domain.com/questions           No. string has both "http" and ".com"
https://www.domain.com/mail               No. string has both "http" and ".com"
https://www.domain.net                    No. string has "http"
oopshttp://www.domain.net                 No. string has "http"
www.domain.com/mail                       No. string has ".com"
/subdomain/thankyou.html                  YES! string has neither "http" or ".com"

Ideally, the rejection of "http" and ".com" would supplement what I currently have: Which is the string must start with a forward slash "/" and end in ".html" which is:

/^\/.+?\.html$/

Any help is appreciated, thank You in advance

2
A simple alternation http|\.com should work.user557597
/http|\.com/ rejects everything I type into the field, so no go. I don't know if different systems are finicky about regex - all I can offer is that it's adobe CQ5's dialog editor regexuser3474152
Well, a regection is what you want right? If the outcome is a non-match, then its a sucess. Can you change the validation to fail = pass? Well try one of Jerry's or mine regex's, if it accepts it, your good to go.user557597
Hey, you got it working with the same style regex Jerry and I posted. I know you don't know about regex's but a little info for you. The regex you edited/listed above /^\/.+?\.html$/ is not actually a valid regex. That regex looks for a slash.BOL.any chars,dot,html,EOS,slash. Its impossible for that to match anything. When you post regex's you should post ones that actuall work.user557597

2 Answers

2
votes

^/.+\.html$ should work completely fine.

Autopsy:

  • ^ the start MUST match whatever is next:
  • / a literal slash (if your modifier is a slash you need to escape this to \/)
  • .+ match as much as possible (any character 1 to infinity times)
  • \.html the literal string .html
  • $ the end MUST be here

Regular expression visualization

Debuggex Demo

0
votes

This can work with negative lookahead:

^\/(?!.*?(http|\.com)).+?\.html$

Online Demo: http://regex101.com/r/dN8uV2