--- a/CharacterArray.st Fri Oct 02 17:23:39 2009 +0200
+++ b/CharacterArray.st Sat Oct 03 12:13:35 2009 +0200
@@ -3568,6 +3568,434 @@
! !
+!CharacterArray methodsFor:'matching - glob expressions'!
+
+compoundMatch:aString
+ "like match, but the receiver may be a compound match pattern,
+ consisting of multiple simple patterns, separated by semicolons.
+ This is usable with fileName pattern fields.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the receiver is the match pattern"
+
+ ^self compoundMatch:aString ignoreCase:false
+
+ "
+ 'f*' match:'foo'
+ 'b*' match:'foo'
+ 'f*;b*' match:'foo'
+ 'f*;b*' match:'bar'
+ 'f*;b*' compoundMatch:'foo'
+ 'f*;b*' compoundMatch:'bar'
+ "
+
+ "Modified: / 30.1.1998 / 11:40:18 / stefan"
+ "Modified: / 16.12.1999 / 01:22:08 / cg"
+!
+
+compoundMatch:aString ignoreCase:ignoreCase
+ "like match, but the receiver may be a compound match pattern,
+ consisting of multiple simple patterns, separated by semicolons.
+ This is usable with fileName pattern fields.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the receiver is the match pattern"
+
+ |matchers|
+
+ matchers := self asCollectionOfSubstringsSeparatedBy:$;.
+ ^ matchers contains:[:aPattern |
+ aPattern match:aString ignoreCase:ignoreCase escapeCharacter:nil
+ ].
+
+"/ matchers do:[:aPattern |
+"/ (aPattern match:aString ignoreCase:ignoreCase) 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'
+ 'f*;b*' compoundMatch:'Foo' ignoreCase:true
+ 'f*;b*' compoundMatch:'Bar' ignoreCase:true
+ 'f*;b*' compoundMatch:'ccc' ignoreCase:true
+ "
+
+ "Modified: / 15.4.1997 / 15:50:33 / cg"
+ "Modified: / 30.1.1998 / 11:40:18 / stefan"
+ "Created: / 16.12.1999 / 01:21:35 / cg"
+!
+
+findMatchString:matchString
+ "like findString/indexOfSubCollection, but allowing match patterns.
+ find matchstring; if found, return the index;
+ if not found, return 0.
+
+ NOTICE: match-meta character interpretation is like in unix-matching,
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the argument is the match pattern"
+
+ ^ self findMatchString:matchString startingAt:1 ignoreCase:false ifAbsent:0
+!
+
+findMatchString:matchString startingAt:index
+ "like findString, but allowing match patterns.
+ find matchstring, starting at index. if found, return the index;
+ if not found, return 0.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the argument is the match pattern"
+
+ ^ self findMatchString:matchString startingAt:index ignoreCase:false ifAbsent:0
+!
+
+findMatchString:matchString startingAt:index ignoreCase:ignoreCase ifAbsent:exceptionBlock
+ "like findString, but allowing match patterns.
+ find matchstring, starting at index. if found, return the index;
+ if not found, return the result of evaluating exceptionBlock.
+ This is a q&d hack - not very efficient.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the argument is the match pattern"
+
+ |firstChar firstSet
+ startIndex "{ Class: SmallInteger }"
+ matchSize "{ Class: SmallInteger }"
+ mySize "{ Class: SmallInteger }"
+ realMatchString lcChar ucChar|
+
+ matchSize := matchString size.
+ matchSize == 0 ifTrue:[^ index]. "empty string matches"
+
+ realMatchString := matchString.
+ (realMatchString endsWith:$*) ifFalse:[
+ realMatchString := realMatchString , '*'.
+ matchSize := matchSize + 1
+ ].
+
+ mySize := self size.
+ firstChar := realMatchString at:1.
+ firstChar == self class matchEscapeCharacter ifTrue:[
+ firstChar := realMatchString at:2.
+ ].
+
+ firstChar asString includesMatchCharacters ifTrue:[
+ index to:mySize do:[:col |
+ (realMatchString match:self from:col to:mySize ignoreCase:ignoreCase)
+ ifTrue:[^ col]
+ ].
+ ^ exceptionBlock value.
+ ].
+
+ lcChar := firstChar asLowercase.
+ ucChar := firstChar asUppercase.
+ (ignoreCase and:[ lcChar ~= ucChar]) ifTrue:[
+ firstSet := Array with:ucChar with:lcChar.
+ startIndex := self indexOfAny:firstSet startingAt:index.
+ ] ifFalse:[
+ startIndex := self indexOf:firstChar startingAt:index.
+ ].
+ [startIndex == 0] whileFalse:[
+ (realMatchString match:self from:startIndex to:mySize ignoreCase:ignoreCase)
+ ifTrue:[^ startIndex].
+ firstSet notNil ifTrue:[
+ startIndex := self indexOfAny:firstSet startingAt:(startIndex + 1).
+ ] ifFalse:[
+ startIndex := self indexOf:firstChar startingAt:(startIndex + 1).
+ ].
+ ].
+ ^ exceptionBlock value
+
+ "
+ 'one two three four' findMatchString:'o[nu]'
+ 'one two three four' findMatchString:'o[nu]' startingAt:3
+ 'one two three four one' findMatchString:'ONE' startingAt:3 ignoreCase:true ifAbsent:0
+ "
+
+ "Modified: 13.9.1997 / 06:31:22 / cg"
+!
+
+includesMatchString:matchString
+ "like includesString, but allowing match patterns.
+ find matchstring; if found, return true, otherwise return false.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the argument is the match pattern"
+
+ ^ (self findMatchString:matchString) ~~ 0
+
+ "
+ 'hello world' includesMatchString:'h*'
+ 'hello world' includesMatchString:'h[aeiou]llo'
+ 'hello world' includesMatchString:'wor*'
+ 'hello world' includesMatchString:'woR*'
+ "
+!
+
+includesMatchString:matchString caseSensitive:caseSensitive
+ "like includesString, but allowing match patterns.
+ find matchstring; if found, return true, otherwise return false.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the argument is the match pattern"
+
+ ^ (self findMatchString:matchString startingAt:1 ignoreCase:caseSensitive not ifAbsent:0) ~~ 0
+
+ "
+ 'hello world' includesMatchString:'h*' caseSensitive:true
+ 'hello world' includesMatchString:'h*' caseSensitive:false
+ 'Hello world' includesMatchString:'h*' caseSensitive:true
+ 'Hello world' includesMatchString:'h*' caseSensitive:false
+
+ 'hello world' includesMatchString:'h[aeiou]llo' caseSensitive:true
+ 'hello world' includesMatchString:'h[aeiou]llo' caseSensitive:false
+
+ 'hello world' includesMatchString:'wor*' caseSensitive:true
+ 'hello world' includesMatchString:'wor*' caseSensitive:false
+
+ 'hello world' includesMatchString:'woR*' caseSensitive:true
+ 'hello world' includesMatchString:'woR*' caseSensitive:false
+ "
+!
+
+match:aString
+ "return true if aString matches self, where self may contain meta-match
+ characters $* (to match any string) or $# (to match any character).
+ or [...] to match a set of characters.
+ Lower/uppercase are considered different.
+ The escape character is the backQuote.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the receiver is the match pattern"
+
+ ^ self match:aString from:1 to:aString size ignoreCase:false
+
+ "
+ '\*f*' match:'f'
+ '\*f*' match:'*f'
+ '*\*f*' match:'*f'
+ '*f*' match:'*f'
+ '*ute*' match:'computer'
+ '*uter' match:'computer'
+ 'uter*' match:'computer'
+ '*ute*' match:''
+ '[abcd]*' match:'computer'
+ '[abcd]*' match:'komputer'
+ '*some*compl*ern*' match:'this is some more complicated pattern match'
+ '*some*compl*ern*' match:'this is another complicated pattern match'
+ '*-hh' match:'anton-h'
+ "
+
+ "Modified: / 9.6.1998 / 18:50:00 / cg"
+!
+
+match:aString escapeCharacter:escape
+ "return true if aString matches self, where self may contain meta-match
+ characters $* (to match any string) or $# (to match any character).
+ or [...] to match a set of characters.
+ Lower/uppercase are considered different.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the receiver is the match pattern"
+
+ ^ self match:aString from:1 to:aString size ignoreCase:false escapeCharacter:escape
+
+ "
+ 'a\b\c\*' match:'a\b\c\d'
+ 'a\b\c\*' match:'a\b\c\d' escapeCharacter:nil
+ "
+!
+
+match:aString from:start to:stop ignoreCase:ignoreCase
+ "return true if part of aString matches myself,
+ where self may contain meta-match
+ characters $* (to match any string) or $# (to match any character)
+ or [...] to match a set of characters.
+ If ignoreCase is true, lower/uppercase are considered the same.
+ The escape character is the backQuote.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the receiver is the match pattern"
+
+ ^ self
+ match:aString from:start to:stop ignoreCase:ignoreCase
+ escapeCharacter:(self class matchEscapeCharacter)
+
+ "
+ '*ute*' match:'12345COMPUTER' from:1 to:5 ignoreCase:true
+ '*ute*' match:'12345COMPUTER' from:6 to:13 ignoreCase:true
+ "
+
+ "Modified: / 10.11.1998 / 21:43:46 / cg"
+!
+
+match:aString from:start to:stop ignoreCase:ignoreCase escapeCharacter:escape
+ "return true if part of aString matches myself,
+ where self may contain meta-match
+ characters $* (to match any string) or $# (to match any character)
+ or [...] to match a set of characters.
+ If ignoreCase is true, lower/uppercase are considered the same.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the receiver is the match pattern"
+
+ |matchScanArray|
+
+ "
+ keep the matchScanArray from the most recent match -
+ avoids parsing the pattern over-and over if multiple searches
+ are done with the same pattern.
+ "
+ (PreviousMatch notNil
+ and:[PreviousMatch key = self]) ifTrue:[
+ matchScanArray := PreviousMatch value
+ ] ifFalse:[
+ matchScanArray := self class matchScanArrayFrom:self escapeCharacter:escape.
+ matchScanArray isNil ifTrue:[
+ 'CharacterArray [info]: invalid matchpattern:''' infoPrint. self infoPrint. ''' comparing for equality.' infoPrintCR.
+ ^ self = aString
+"/ ^ false
+ ].
+ PreviousMatch := self -> matchScanArray.
+ ].
+
+ ^ self class
+ matchScan:matchScanArray
+ from:1 to:matchScanArray size
+ with:aString
+ from:start to:stop
+ ignoreCase:ignoreCase
+
+ "
+ '*ute*' match:'12345COMPUTER' from:1 to:5 ignoreCase:true
+ '*ute*' match:'12345COMPUTER' from:6 to:13 ignoreCase:true
+ "
+
+ "Modified: / 10.11.1998 / 21:43:46 / cg"
+!
+
+match:aString ignoreCase:ignoreCase
+ "return true if aString matches self, where self may contain meta-match
+ characters $* (to match any string) or $# (to match any character)
+ or [...] to match a set of characters.
+ If ignoreCase is true, lower/uppercase are considered the same.
+ The escape character is the backQuote.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the receiver is the match pattern"
+
+ ^ self match:aString from:1 to:aString size ignoreCase:ignoreCase
+
+ "
+ '*ute*' match:'COMPUTER' ignoreCase:true
+ '*uter' match:'COMPUTER' ignoreCase:false
+ '[abcd]*' match:'computer' ignoreCase:false
+ '[abcd]*' match:'Computer' ignoreCase:false
+ '[a-k]*' match:'komputer' ignoreCase:false
+ '[a-k]*' match:'zomputer' ignoreCase:false
+ '[a-k]*' match:'Komputer' ignoreCase:false
+ '[a-k]*' match:'Komputer' ignoreCase:true
+ '*some*compl*ern*' match:'this is some more complicated pattern match' ignoreCase:true
+ '*some*compl*ern*' match:'this is another complicated pattern match' ignoreCase:true
+
+ Time millisecondsToRun:[
+ Symbol allInstancesDo:[:sym |
+ '[ab]*' match:sym ignoreCase:false
+ ]
+ ].
+ Time millisecondsToRun:[
+ Symbol allInstancesDo:[:sym |
+ '*at:*' match:sym ignoreCase:false
+ ]
+ ].
+ "
+
+ "Modified: 2.4.1997 / 17:28:58 / cg"
+!
+
+match:aString ignoreCase:ignoreCase escapeCharacter:escape
+ "return true if aString matches self, where self may contain meta-match
+ characters $* (to match any string) or $# (to match any character)
+ or [...] to match a set of characters.
+ If ignoreCase is true, lower/uppercase are considered the same.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the receiver is the match pattern"
+
+ ^ self match:aString from:1 to:aString size ignoreCase:ignoreCase escapeCharacter:escape
+
+ "
+ '*ute*' match:'COMPUTER' ignoreCase:true
+ '*uter' match:'COMPUTER' ignoreCase:false
+ '[abcd]*' match:'computer' ignoreCase:false
+ '[abcd]*' match:'Computer' ignoreCase:false
+ '[a-k]*' match:'komputer' ignoreCase:false
+ '[a-k]*' match:'zomputer' ignoreCase:false
+ '[a-k]*' match:'Komputer' ignoreCase:false
+ '[a-k]*' match:'Komputer' ignoreCase:true
+ '*some*compl*ern*' match:'this is some more complicated pattern match' ignoreCase:true
+ '*some*compl*ern*' match:'this is another complicated pattern match' ignoreCase:true
+
+ Time millisecondsToRun:[
+ Symbol allInstancesDo:[:sym |
+ '[ab]*' match:sym ignoreCase:false
+ ]
+ ].
+ Time millisecondsToRun:[
+ Symbol allInstancesDo:[:sym |
+ '*at:*' match:sym ignoreCase:false
+ ]
+ ].
+ "
+
+ "Modified: 2.4.1997 / 17:28:58 / cg"
+!
+
+matches:aPatternString
+ "return true if the receiver matches aString, where aPatternString may contain meta-match
+ characters $* (to match any string) or $# (to match any character).
+ or [...] to match a set of characters.
+ Lower/uppercase are considered different.
+
+ NOTICE: match-meta character interpretation is like in unix-matching (glob),
+ NOT the ST-80 meaning.
+ NOTICE: this is different from regex matching (see matchesRegex:)
+ NOTICE: the receiver is the match pattern"
+
+ ^ aPatternString match:self
+! !
+
+
+
!CharacterArray methodsFor:'padded copying'!
centerPaddedTo:newSize
@@ -3722,432 +4150,6 @@
"
! !
-!CharacterArray methodsFor:'pattern matching'!
-
-compoundMatch:aString
- "like match, but the receiver may be a compound match pattern,
- consisting of multiple simple patterns, separated by semicolons.
- This is usable with fileName pattern fields.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the receiver is the match pattern"
-
- ^self compoundMatch:aString ignoreCase:false
-
- "
- 'f*' match:'foo'
- 'b*' match:'foo'
- 'f*;b*' match:'foo'
- 'f*;b*' match:'bar'
- 'f*;b*' compoundMatch:'foo'
- 'f*;b*' compoundMatch:'bar'
- "
-
- "Modified: / 30.1.1998 / 11:40:18 / stefan"
- "Modified: / 16.12.1999 / 01:22:08 / cg"
-!
-
-compoundMatch:aString ignoreCase:ignoreCase
- "like match, but the receiver may be a compound match pattern,
- consisting of multiple simple patterns, separated by semicolons.
- This is usable with fileName pattern fields.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the receiver is the match pattern"
-
- |matchers|
-
- matchers := self asCollectionOfSubstringsSeparatedBy:$;.
- ^ matchers contains:[:aPattern |
- aPattern match:aString ignoreCase:ignoreCase escapeCharacter:nil
- ].
-
-"/ matchers do:[:aPattern |
-"/ (aPattern match:aString ignoreCase:ignoreCase) 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'
- 'f*;b*' compoundMatch:'Foo' ignoreCase:true
- 'f*;b*' compoundMatch:'Bar' ignoreCase:true
- 'f*;b*' compoundMatch:'ccc' ignoreCase:true
- "
-
- "Modified: / 15.4.1997 / 15:50:33 / cg"
- "Modified: / 30.1.1998 / 11:40:18 / stefan"
- "Created: / 16.12.1999 / 01:21:35 / cg"
-!
-
-findMatchString:matchString
- "like findString/indexOfSubCollection, but allowing match patterns.
- find matchstring; if found, return the index;
- if not found, return 0.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the argument is the match pattern"
-
- ^ self findMatchString:matchString startingAt:1 ignoreCase:false ifAbsent:0
-!
-
-findMatchString:matchString startingAt:index
- "like findString, but allowing match patterns.
- find matchstring, starting at index. if found, return the index;
- if not found, return 0.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the argument is the match pattern"
-
- ^ self findMatchString:matchString startingAt:index ignoreCase:false ifAbsent:0
-!
-
-findMatchString:matchString startingAt:index ignoreCase:ignoreCase ifAbsent:exceptionBlock
- "like findString, but allowing match patterns.
- find matchstring, starting at index. if found, return the index;
- if not found, return the result of evaluating exceptionBlock.
- This is a q&d hack - not very efficient.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the argument is the match pattern"
-
- |firstChar firstSet
- startIndex "{ Class: SmallInteger }"
- matchSize "{ Class: SmallInteger }"
- mySize "{ Class: SmallInteger }"
- realMatchString lcChar ucChar|
-
- matchSize := matchString size.
- matchSize == 0 ifTrue:[^ index]. "empty string matches"
-
- realMatchString := matchString.
- (realMatchString endsWith:$*) ifFalse:[
- realMatchString := realMatchString , '*'.
- matchSize := matchSize + 1
- ].
-
- mySize := self size.
- firstChar := realMatchString at:1.
- firstChar == self class matchEscapeCharacter ifTrue:[
- firstChar := realMatchString at:2.
- ].
-
- firstChar asString includesMatchCharacters ifTrue:[
- index to:mySize do:[:col |
- (realMatchString match:self from:col to:mySize ignoreCase:ignoreCase)
- ifTrue:[^ col]
- ].
- ^ exceptionBlock value.
- ].
-
- lcChar := firstChar asLowercase.
- ucChar := firstChar asUppercase.
- (ignoreCase and:[ lcChar ~= ucChar]) ifTrue:[
- firstSet := Array with:ucChar with:lcChar.
- startIndex := self indexOfAny:firstSet startingAt:index.
- ] ifFalse:[
- startIndex := self indexOf:firstChar startingAt:index.
- ].
- [startIndex == 0] whileFalse:[
- (realMatchString match:self from:startIndex to:mySize ignoreCase:ignoreCase)
- ifTrue:[^ startIndex].
- firstSet notNil ifTrue:[
- startIndex := self indexOfAny:firstSet startingAt:(startIndex + 1).
- ] ifFalse:[
- startIndex := self indexOf:firstChar startingAt:(startIndex + 1).
- ].
- ].
- ^ exceptionBlock value
-
- "
- 'one two three four' findMatchString:'o[nu]'
- 'one two three four' findMatchString:'o[nu]' startingAt:3
- 'one two three four one' findMatchString:'ONE' startingAt:3 ignoreCase:true ifAbsent:0
- "
-
- "Modified: 13.9.1997 / 06:31:22 / cg"
-!
-
-includesMatchString:matchString
- "like includesString, but allowing match patterns.
- find matchstring; if found, return true, otherwise return false.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the argument is the match pattern"
-
- ^ (self findMatchString:matchString) ~~ 0
-
- "
- 'hello world' includesMatchString:'h*'
- 'hello world' includesMatchString:'h[aeiou]llo'
- 'hello world' includesMatchString:'wor*'
- 'hello world' includesMatchString:'woR*'
- "
-!
-
-includesMatchString:matchString caseSensitive:caseSensitive
- "like includesString, but allowing match patterns.
- find matchstring; if found, return true, otherwise return false.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the argument is the match pattern"
-
- ^ (self findMatchString:matchString startingAt:1 ignoreCase:caseSensitive not ifAbsent:0) ~~ 0
-
- "
- 'hello world' includesMatchString:'h*' caseSensitive:true
- 'hello world' includesMatchString:'h*' caseSensitive:false
- 'Hello world' includesMatchString:'h*' caseSensitive:true
- 'Hello world' includesMatchString:'h*' caseSensitive:false
-
- 'hello world' includesMatchString:'h[aeiou]llo' caseSensitive:true
- 'hello world' includesMatchString:'h[aeiou]llo' caseSensitive:false
-
- 'hello world' includesMatchString:'wor*' caseSensitive:true
- 'hello world' includesMatchString:'wor*' caseSensitive:false
-
- 'hello world' includesMatchString:'woR*' caseSensitive:true
- 'hello world' includesMatchString:'woR*' caseSensitive:false
- "
-!
-
-match:aString
- "return true if aString matches self, where self may contain meta-match
- characters $* (to match any string) or $# (to match any character).
- or [...] to match a set of characters.
- Lower/uppercase are considered different.
- The escape character is the backQuote.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the receiver is the match pattern"
-
- ^ self match:aString from:1 to:aString size ignoreCase:false
-
- "
- '\*f*' match:'f'
- '\*f*' match:'*f'
- '*\*f*' match:'*f'
- '*f*' match:'*f'
- '*ute*' match:'computer'
- '*uter' match:'computer'
- 'uter*' match:'computer'
- '*ute*' match:''
- '[abcd]*' match:'computer'
- '[abcd]*' match:'komputer'
- '*some*compl*ern*' match:'this is some more complicated pattern match'
- '*some*compl*ern*' match:'this is another complicated pattern match'
- '*-hh' match:'anton-h'
- "
-
- "Modified: / 9.6.1998 / 18:50:00 / cg"
-!
-
-match:aString escapeCharacter:escape
- "return true if aString matches self, where self may contain meta-match
- characters $* (to match any string) or $# (to match any character).
- or [...] to match a set of characters.
- Lower/uppercase are considered different.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the receiver is the match pattern"
-
- ^ self match:aString from:1 to:aString size ignoreCase:false escapeCharacter:escape
-
- "
- 'a\b\c\*' match:'a\b\c\d'
- 'a\b\c\*' match:'a\b\c\d' escapeCharacter:nil
- "
-!
-
-match:aString from:start to:stop ignoreCase:ignoreCase
- "return true if part of aString matches myself,
- where self may contain meta-match
- characters $* (to match any string) or $# (to match any character)
- or [...] to match a set of characters.
- If ignoreCase is true, lower/uppercase are considered the same.
- The escape character is the backQuote.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the receiver is the match pattern"
-
- ^ self
- match:aString from:start to:stop ignoreCase:ignoreCase
- escapeCharacter:(self class matchEscapeCharacter)
-
- "
- '*ute*' match:'12345COMPUTER' from:1 to:5 ignoreCase:true
- '*ute*' match:'12345COMPUTER' from:6 to:13 ignoreCase:true
- "
-
- "Modified: / 10.11.1998 / 21:43:46 / cg"
-!
-
-match:aString from:start to:stop ignoreCase:ignoreCase escapeCharacter:escape
- "return true if part of aString matches myself,
- where self may contain meta-match
- characters $* (to match any string) or $# (to match any character)
- or [...] to match a set of characters.
- If ignoreCase is true, lower/uppercase are considered the same.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the receiver is the match pattern"
-
- |matchScanArray|
-
- "
- keep the matchScanArray from the most recent match -
- avoids parsing the pattern over-and over if multiple searches
- are done with the same pattern.
- "
- (PreviousMatch notNil
- and:[PreviousMatch key = self]) ifTrue:[
- matchScanArray := PreviousMatch value
- ] ifFalse:[
- matchScanArray := self class matchScanArrayFrom:self escapeCharacter:escape.
- matchScanArray isNil ifTrue:[
- 'CharacterArray [info]: invalid matchpattern:''' infoPrint. self infoPrint. ''' comparing for equality.' infoPrintCR.
- ^ self = aString
-"/ ^ false
- ].
- PreviousMatch := self -> matchScanArray.
- ].
-
- ^ self class
- matchScan:matchScanArray
- from:1 to:matchScanArray size
- with:aString
- from:start to:stop
- ignoreCase:ignoreCase
-
- "
- '*ute*' match:'12345COMPUTER' from:1 to:5 ignoreCase:true
- '*ute*' match:'12345COMPUTER' from:6 to:13 ignoreCase:true
- "
-
- "Modified: / 10.11.1998 / 21:43:46 / cg"
-!
-
-match:aString ignoreCase:ignoreCase
- "return true if aString matches self, where self may contain meta-match
- characters $* (to match any string) or $# (to match any character)
- or [...] to match a set of characters.
- If ignoreCase is true, lower/uppercase are considered the same.
- The escape character is the backQuote.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the receiver is the match pattern"
-
- ^ self match:aString from:1 to:aString size ignoreCase:ignoreCase
-
- "
- '*ute*' match:'COMPUTER' ignoreCase:true
- '*uter' match:'COMPUTER' ignoreCase:false
- '[abcd]*' match:'computer' ignoreCase:false
- '[abcd]*' match:'Computer' ignoreCase:false
- '[a-k]*' match:'komputer' ignoreCase:false
- '[a-k]*' match:'zomputer' ignoreCase:false
- '[a-k]*' match:'Komputer' ignoreCase:false
- '[a-k]*' match:'Komputer' ignoreCase:true
- '*some*compl*ern*' match:'this is some more complicated pattern match' ignoreCase:true
- '*some*compl*ern*' match:'this is another complicated pattern match' ignoreCase:true
-
- Time millisecondsToRun:[
- Symbol allInstancesDo:[:sym |
- '[ab]*' match:sym ignoreCase:false
- ]
- ].
- Time millisecondsToRun:[
- Symbol allInstancesDo:[:sym |
- '*at:*' match:sym ignoreCase:false
- ]
- ].
- "
-
- "Modified: 2.4.1997 / 17:28:58 / cg"
-!
-
-match:aString ignoreCase:ignoreCase escapeCharacter:escape
- "return true if aString matches self, where self may contain meta-match
- characters $* (to match any string) or $# (to match any character)
- or [...] to match a set of characters.
- If ignoreCase is true, lower/uppercase are considered the same.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the receiver is the match pattern"
-
- ^ self match:aString from:1 to:aString size ignoreCase:ignoreCase escapeCharacter:escape
-
- "
- '*ute*' match:'COMPUTER' ignoreCase:true
- '*uter' match:'COMPUTER' ignoreCase:false
- '[abcd]*' match:'computer' ignoreCase:false
- '[abcd]*' match:'Computer' ignoreCase:false
- '[a-k]*' match:'komputer' ignoreCase:false
- '[a-k]*' match:'zomputer' ignoreCase:false
- '[a-k]*' match:'Komputer' ignoreCase:false
- '[a-k]*' match:'Komputer' ignoreCase:true
- '*some*compl*ern*' match:'this is some more complicated pattern match' ignoreCase:true
- '*some*compl*ern*' match:'this is another complicated pattern match' ignoreCase:true
-
- Time millisecondsToRun:[
- Symbol allInstancesDo:[:sym |
- '[ab]*' match:sym ignoreCase:false
- ]
- ].
- Time millisecondsToRun:[
- Symbol allInstancesDo:[:sym |
- '*at:*' match:sym ignoreCase:false
- ]
- ].
- "
-
- "Modified: 2.4.1997 / 17:28:58 / cg"
-!
-
-matches:aPatternString
- "return true if the receiver matches aString, where aPatternString may contain meta-match
- characters $* (to match any string) or $# (to match any character).
- or [...] to match a set of characters.
- Lower/uppercase are considered different.
-
- NOTICE: match-meta character interpretation is like in unix-matching,
- NOT the ST-80 meaning.
- NOTICE: this is different from regex matching (see matchesRegex:)
- NOTICE: the receiver is the match pattern"
-
- ^ aPatternString match:self
-! !
-
!CharacterArray methodsFor:'printing & storing'!
article
@@ -4515,7 +4517,6 @@
! !
-
!CharacterArray methodsFor:'special string converting'!
expandPlaceholdersWith:argArrayOrDictionary
@@ -5721,11 +5722,11 @@
!CharacterArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.409 2009-09-30 12:13:58 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.410 2009-10-03 10:13:35 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.409 2009-09-30 12:13:58 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.410 2009-10-03 10:13:35 cg Exp $'
! !
CharacterArray initialize!