I\'m writing an XML schema and need to prevent the text of an element from matching certain values. (Eg. the variableName element cannot match \'int\', \'byte\', \'string\'
Without negative lookahead, this is pretty tedious. Attached is a regex that works with some unit tests. This is written in Perl, not XSD, but it's pretty basic regex so it should work... You should remove the whitespace from the regex before using it. I added the whitespace just to make it a little easier to read.
Note: I don't know if "\A" and "\z" are allowed in XSD. If not, replace with "^" and "$" respectively.
use Test::More 'no_plan';
my $re = qr/\A(\z|[^ibs]
|i(\z|[^n]|n(\z|[^t]|t.))
|b(\z|[^y]|y(\z|[^t]|t(\z|[^e]|e.)))
|s(\z|[^t]|t(\z|[^r]|r(\z|[^i]|i(\z|[^n]|n(\z|[^g]|g.))))))/x;
for my $str ( qw(inter bytes ins str strings in sdgsdfger i b s by byt bite st \
str stri strin strink) ) {
like($str, $re, $str);
}
for my $str ( qw(int byte string) ) {
unlike($str, $re, $str);
}