Regular Expressions in Data Definition

jklingman's Avatar


28 Mar, 2011 06:26 PM

I'm very new to regular expressions, but was trying one out for a URL field in a Data Definition. I want to ensure that the user has started the URL with "http://" or "https://". I tried entering this:


Cascade appears to be ignoring it: I can enter a value of "1" into the field. Any ideas as to what I'm doing wrong? I found another posting stating that there's a bug in Cascade where it doesn't enforce regex if the field isn't required, but my field is required. Thanks for any help.

  1. 1 Posted by Charlie Holder on 28 Mar, 2011 07:14 PM

    Charlie Holder's Avatar

    Yes, the regular expression option on an input field won't run unless the field is required.

    I'm no regexpert, but one reason why your regex might not work is: I seem to remember something about the expression needing matching opening and closing characters to signify the expression starting and ending. I have run into that issue in the past.

    I use this cheat sheet sometimes for a quick reference for matching.

    A quick Google search returns some helpful links. This one has a pretty extensive discussion going on, but I wasn't able to make their super long, RFC-compliant regex work within Cascade. (Parse error somewhere.)

    Another solution could be to provide some default text for the input field. In the default text region you could manually type in "http://" so that all pages using the Data Definition begin with that string.

  2. 2 Posted by Charlie Holder on 28 Mar, 2011 07:23 PM

    Charlie Holder's Avatar

    On second thought, the example regex that I gave is pretty bad. It doesn't match a lot of things.

    I can try to find a better one if you're still having trouble writing your own. But if you're just writing to check for an http(s) beginning, that might be pretty simple.

  3. 3 Posted by Klingman, Justi... on 29 Mar, 2011 01:30 PM

    Klingman, Justin's Avatar

    No content.

  4. 4 Posted by Charlie Holder on 29 Mar, 2011 01:52 PM

    Charlie Holder's Avatar

    See how this works for you. I did some more testing on it this morning.


  5. 5 Posted by Klingman, Justi... on 29 Mar, 2011 05:47 PM

    Klingman, Justin's Avatar


    I tried the below, and Cascade still didn't catch an invalid entry (I do have the field marked as required). I'm running Cascade 6.7.4. Is it working in your version?

  6. 6 Posted by Charlie Holder on 29 Mar, 2011 06:06 PM

    Charlie Holder's Avatar


    1. What are some test inputs you're giving it?
    2. Paste your Data Definition XML in here too.
    3. Have you seen any kind of error message before? Like if you were to change it to something that only allowed numbers and then type in a letter, do you get an error message?

    Yes, it is working in my version for 6.7.5

  7. 7 Posted by jklingman on 30 Mar, 2011 02:52 AM

    jklingman's Avatar
    1. I just tried to put in random characters, like "skfjlkds".

    2. I tried putting the XML into here, didn't work. So it's attached.

    3. This is my first attempt at using regex in a DD, so I haven't seen any other kind of errors, no. Errors are working on the DD for required fields, but that's it.

  8. 8 Posted by jklingman on 30 Mar, 2011 02:54 AM

    jklingman's Avatar

    Attached file.

  9. 9 Posted by Charlie Holder on 30 Mar, 2011 12:33 PM

    Charlie Holder's Avatar

    Are copying/pasting each of the regular expressions from email?

    I see that your regex value in your Data Definition contains backticks. Those characters are part of the forum's Markdown syntax for transforming text to look like code blocks.

    Try removing the initial and ending backticks from your regex.

  10. 10 Posted by Klingman, Justi... on 30 Mar, 2011 01:16 PM

    Klingman, Justin's Avatar

    No content.

  11. 11 Posted by Charlie Holder on 30 Mar, 2011 01:25 PM

    Charlie Holder's Avatar

    Sorry but, what does "no content" mean? This is the second time and I'm just not quite sure.

  12. 12 Posted by jklingman on 30 Mar, 2011 01:30 PM

    jklingman's Avatar

    Not sure, because I replied to the email like you're allowed to do. Sorry about that. I said:

    Thanks Charlie! That's working perfectly now...sorry about the extra characters. I really appreciate your help!

  13. 13 Posted by Charlie Holder on 30 Mar, 2011 01:34 PM

    Charlie Holder's Avatar

    Sure. Let me know if anything changes.

  14. Charlie Holder closed this discussion on 30 Mar, 2011 01:34 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac