Home
TeamSite
Regex Over Multiple Lines in DCT
cboyd2
Hello,
I am trying to validate user input in a textarea (multi-line). The Regex I have validates the first line the user enters but not any line after that. Is there a way to validate multiple lines in a textarea?
Here is my Regex.......
[0-9 a-zA-Z-_]+[,][0-9 a-zA-Z-_]+[[][0-9]+[]];
Thanks,
-Chuck
Find more posts tagged with
Comments
Migrateduser
You can use the "m" option to span multiple lines in a regular expression. So, basically, the ^ would refer to the beginning of the search string and $ would refer to the end, as always, but the "m" provides multi-line support.
Dave
Current Environment(s):
(1) TS 6.1 SP2 on W2K3
(2) TS 6.1 SP1 on W2K
(3) TS 6.1 SP2 on Win2K
Michael
You might also find this post helpful:
http://devnet.interwoven.com/forums/cgi-bin/showflat.pl?Cat=&Board=PRODUCTS_TEMPLATING&Number=6398&page=&view=&sb=&o=&vc=1
Cheers
Michael
cboyd2
Thanks Dave,
How would the syntax go? I tried ......
[0-9 a-zA-Z-_]+[,][0-9 a-zA-Z-_]+[[][0-9]+[]];\m
&
^[0-9 a-zA-Z-_]+[,][0-9 a-zA-Z-_]+[[][0-9]+[]];\m?$
with no luck.
-Chuck
Migrateduser
Are you doing it in Perl or in Javascript? Post your code in more context so I can get an idea of how you're using it.
Dave
Current Environment(s):
(1) TS 6.1 SP2 on W2K3
(2) TS 6.1 SP1 on W2K
(3) TS 6.1 SP2 on Win2K
cboyd2
This is in the DCT itself.
<textarea validation-regex="^[0-9 a-zA-Z-_]+[,][0-9 a-zA-Z-_]+[[][0-9]+[]];\m?$" required="t" cols="41" rows="4">
-cb
Migrateduser
Oh, yikes. Okay, I don't think there's a way to do that, but you can certainly validate it on the FormAPI side and I THINK it'll accept the "m" option.
var re = new RegExp("^[0-9 a-zA-Z-_]+[,][0-9 a-zA-Z-_]+[[][0-9]+[]];","m");
if (!(string.match(re))) {
--- throw error and return false ---
}
Current Environment(s):
(1) TS 6.1 SP2 on W2K3
(2) TS 6.1 SP1 on W2K
(3) TS 6.1 SP2 on Win2K
Adam Stoller
In addition to the thread that Michael referenced you might also want to look at
http://devnet.interwoven.com/site.fcgi/techlib/047665
(
Note:
the stylesheet for the KB articles unfortunately tends to use a rather-hard-to-read coloring for 'pre' formatted code - so you may need to copy the text and paste it into something else to read it
)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com