added compoundMatch
authorClaus Gittinger <cg@exept.de>
Tue, 15 Apr 1997 15:51:02 +0200
changeset 2551 46c18418fb05
parent 2550 0832a8bc6ec4
child 2552 c4eae9ddfd0a
added compoundMatch
CharArray.st
CharacterArray.st
--- a/CharArray.st	Tue Apr 15 15:43:16 1997 +0200
+++ b/CharArray.st	Tue Apr 15 15:51:02 1997 +0200
@@ -2934,6 +2934,31 @@
 
 !CharacterArray methodsFor:'pattern matching'!
 
+compoundMatch:aString
+    "like match, but the receiver may be a compount match pattern,
+     consisting of multiple simple patterns, separated by semicolons.
+     This is usable with fileName pattern fields."
+
+    |matchers|
+
+    matchers := self asCollectionOfSubstringsSeparatedBy:$;.
+    matchers do:[:aPattern |
+        (aPattern match:aString) ifTrue:[^ true].
+    ].
+    ^ false.
+
+    "
+     'f*' match:'foo'       
+     'b*' match:'foo'       
+     'f*;b*' match:'foo'    
+     'f*;b*' match:'bar'    
+     'f*;b*' compoundMatch:'foo' 
+     'f*;b*' compoundMatch:'bar' 
+    "
+
+    "Modified: 15.4.1997 / 15:50:33 / cg"
+!
+
 findMatchString:matchString
     "like findString/indexOfSubCollection, but allowing match patterns.
      find matchstring; if found, return the index;
@@ -4246,5 +4271,5 @@
 !CharacterArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/CharArray.st,v 1.106 1997-04-11 19:30:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/CharArray.st,v 1.107 1997-04-15 13:51:02 cg Exp $'
 ! !
--- a/CharacterArray.st	Tue Apr 15 15:43:16 1997 +0200
+++ b/CharacterArray.st	Tue Apr 15 15:51:02 1997 +0200
@@ -2934,6 +2934,31 @@
 
 !CharacterArray methodsFor:'pattern matching'!
 
+compoundMatch:aString
+    "like match, but the receiver may be a compount match pattern,
+     consisting of multiple simple patterns, separated by semicolons.
+     This is usable with fileName pattern fields."
+
+    |matchers|
+
+    matchers := self asCollectionOfSubstringsSeparatedBy:$;.
+    matchers do:[:aPattern |
+        (aPattern match:aString) ifTrue:[^ true].
+    ].
+    ^ false.
+
+    "
+     'f*' match:'foo'       
+     'b*' match:'foo'       
+     'f*;b*' match:'foo'    
+     'f*;b*' match:'bar'    
+     'f*;b*' compoundMatch:'foo' 
+     'f*;b*' compoundMatch:'bar' 
+    "
+
+    "Modified: 15.4.1997 / 15:50:33 / cg"
+!
+
 findMatchString:matchString
     "like findString/indexOfSubCollection, but allowing match patterns.
      find matchstring; if found, return the index;
@@ -4246,5 +4271,5 @@
 !CharacterArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.106 1997-04-11 19:30:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.107 1997-04-15 13:51:02 cg Exp $'
 ! !