summaryrefslogtreecommitdiff
path: root/fml/lib/FML/Restriction/Base.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2003-01-25 09:14:04 +0000
committerfukachan <fukachan>2003-01-25 09:14:04 +0000
commita43a66146f737a410a9b8008d4d3eccb9308fc8f (patch)
treeedf8577f08dc0121b07024dc929b1219dd99281a /fml/lib/FML/Restriction/Base.pm
parentcd4628ec752ca82dcee613bafada957c18d0501c (diff)
downloadfml8-a43a66146f737a410a9b8008d4d3eccb9308fc8f.tar.gz
fml8-a43a66146f737a410a9b8008d4d3eccb9308fc8f.tar.bz2
fml8-a43a66146f737a410a9b8008d4d3eccb9308fc8f.zip
implement FML::Restriction::Base::regexp_match() and
switched to use it.
Diffstat (limited to 'fml/lib/FML/Restriction/Base.pm')
-rw-r--r--fml/lib/FML/Restriction/Base.pm40
1 files changed, 39 insertions, 1 deletions
diff --git a/fml/lib/FML/Restriction/Base.pm b/fml/lib/FML/Restriction/Base.pm
index 1f4b8455..179383b8 100644
--- a/fml/lib/FML/Restriction/Base.pm
+++ b/fml/lib/FML/Restriction/Base.pm
@@ -3,7 +3,7 @@
# Copyright (C) 2001,2002,2003 Ken'ichi Fukamachi
# All rights reserved.
#
-# $FML$
+# $FML: Base.pm,v 1.17 2003/01/03 07:04:08 fukachan Exp $
#
package FML::Restriction::Base;
@@ -154,6 +154,44 @@ sub regexp
}
+=head2 regexp_match( class, string )
+
+check if C<string> matches regexp specified by C<class>.
+return 1 or undef.
+
+ my $obj = new FML::Restriction::Base;
+ if ($obj->regexp_match( "address", $address ) {
+ ... do something ...
+ }
+
+=cut
+
+
+# Descriptions: return allowed regexp for $class.
+# Arguments: OBJ($self) STR($class) STR($string)
+# Side Effects: none
+# Return Value: 1 or UNDEF
+sub regexp_match
+{
+ my ($self, $class, $string) = @_;
+
+ if (defined $basic_variable{ $class }) {
+ my $regexp = $basic_variable{ $class };
+
+ if ($string =~ /^($regexp)$/) {
+ return 1;
+ }
+ else {
+ return undef;
+ }
+
+ }
+ else {
+ return undef;
+ }
+}
+
+
#
# debug
#