tag:help-archives.hannonhill.com,2010-02-09:/discussions/how-do-i/380-regular-expressions-in-data-definitionCascade CMS: Discussion 2014-07-23T12:29:15Ztag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-28T19:14:00Z2011-03-30T13:29:11ZRegular Expressions in Data Definition<div><p>Yes, the regular expression option on an input field won't run
unless the field is required.</p>
<p>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.</p>
<p>I use <a href="http://regexlib.com/CheatSheet.aspx">this cheat
sheet</a> sometimes for a quick reference for matching.</p>
<p>A <a href=
"http://www.google.com/search?q=regex+to+test+url">quick Google
search</a> returns some helpful links. <a href=
"http://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url">
This one</a> 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.)</p>
<p><strong>Another solution</strong> could be to provide some
default text for the input field. In the default text region you
could manually type in "<a href="http://">http://</a>" so that all
pages using the Data Definition begin with that string.</p></div>Charlie Holdertag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-28T19:23:31Z2011-03-28T19:23:31ZRegular Expressions in Data Definition<div><p>On second thought, the example regex that I gave is pretty bad.
It doesn't match a lot of things.</p>
<p>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.</p></div>Charlie Holdertag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-29T13:30:25Z2011-03-29T13:30:25ZRegular Expressions in Data Definition<div><p>No content.</p></div>Klingman, Justintag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-29T13:52:42Z2011-03-29T13:52:42ZRegular Expressions in Data Definition<div><p>See how this works for you. I did some more testing on it this
morning.</p>
<p><code>/^http[s]?:\/\/[a-zA-Z0-9.-/]+$/</code></p></div>Charlie Holdertag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-29T17:47:16Z2011-03-29T17:47:16ZRegular Expressions in Data Definition<div><p>Charlie,</p>
<p>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?</p></div>Klingman, Justintag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-29T18:06:12Z2011-03-29T18:06:12ZRegular Expressions in Data Definition<div><p>Hmmm.</p>
<ol>
<li>What are some test inputs you're giving it?<br></li>
<li>Paste your Data Definition XML in here too.<br></li>
<li>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?</li>
</ol>
<p>Yes, it is working in my version for 6.7.5</p></div>Charlie Holdertag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-30T02:52:45Z2011-03-30T02:53:52ZRegular Expressions in Data Definition<div><ol>
<li>
<p>I just tried to put in random characters, like "skfjlkds".</p>
</li>
<li>
<p>I tried putting the XML into here, didn't work. So it's
attached.</p>
</li>
<li>
<p>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.</p>
</li>
</ol></div>jklingmantag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-30T02:54:07Z2011-03-30T02:54:07ZRegular Expressions in Data Definition<div><p>Attached file.</p></div>jklingmantag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-30T12:33:59Z2011-03-30T12:33:59ZRegular Expressions in Data Definition<div><p>Are copying/pasting each of the regular expressions from
email?</p>
<p>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.</p>
<p>Try removing the initial and ending backticks from your
regex.</p></div>Charlie Holdertag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-30T13:16:47Z2011-03-30T13:16:47ZRegular Expressions in Data Definition<div><p>No content.</p></div>Klingman, Justintag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-30T13:25:24Z2011-03-30T13:25:24ZRegular Expressions in Data Definition<div><p>Sorry but, what does "no content" mean? This is the second time
and I'm just not quite sure.</p></div>Charlie Holdertag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-30T13:30:12Z2011-03-30T13:30:12ZRegular Expressions in Data Definition<div><p>Not sure, because I replied to the email like you're allowed to
do. Sorry about that. I said:</p>
<p>Thanks Charlie! That's working perfectly now...sorry about the
extra characters. I really appreciate your help!</p></div>jklingmantag:help-archives.hannonhill.com,2010-02-09:Comment/62894912011-03-30T13:34:40Z2011-03-30T13:34:40ZRegular Expressions in Data Definition<div><p>Sure. Let me know if anything changes.</p></div>Charlie Holder