StringUtilities.st
changeset 4970 60474b8d086d
parent 4939 0d3a5e4dd07f
equal deleted inserted replaced
4969:9acd20c528a3 4970:60474b8d086d
   349 "/            ].
   349 "/            ].
   350 "/            self stringOfCurrentSearchList:stringToSearchFor.
   350 "/            self stringOfCurrentSearchList:stringToSearchFor.
   351         ]
   351         ]
   352     ].
   352     ].
   353 
   353 
   354     Regex::RxParser regexErrorSignal handle:[:ex |
   354     Error handle:[:ex |
   355         self notify:('Invalid regex Pattern.').
   355         self notify:('Invalid pattern: ',ex description).
   356         ^ nil
   356         ^ nil
   357     ] do:[
   357     ] do:[
   358         |lcString shortString regexPattern regexPatterns|
   358         |lcString shortString regexPattern regexPatterns|
   359 
   359 
   360         stringsToSearchFor isNil ifTrue:[
   360         stringsToSearchFor isNil ifTrue:[
   386                         ] ifFalse:[
   386                         ] ifFalse:[
   387                             lcString := shortString asLowercase.
   387                             lcString := shortString asLowercase.
   388                             checkFunction := [:s | s asLowercase startsWith:lcString].
   388                             checkFunction := [:s | s asLowercase startsWith:lcString].
   389                         ]
   389                         ]
   390                     ] ifFalse:[
   390                     ] ifFalse:[
   391                         regexPattern := searchIsCaseSensitive ifTrue:[stringToSearchFor asRegex] ifFalse:[stringToSearchFor asRegexIgnoringCase].
   391                         regexPattern := searchIsCaseSensitive 
       
   392                                                 ifTrue:[stringToSearchFor asRegex] 
       
   393                                                 ifFalse:[stringToSearchFor asRegexIgnoringCase].
   392                         checkFunction := [:s | regexPattern hasMatchesIn:s].
   394                         checkFunction := [:s | regexPattern hasMatchesIn:s].
   393                     ].
   395                     ].
   394                 ].
   396                 ].
   395             ] ifFalse:[
   397             ] ifFalse:[
   396                 searchForRegexPattern ifTrue:[
   398                 searchForRegexPattern ifTrue:[
   397                     regexPattern := searchIsCaseSensitive ifTrue:[stringToSearchFor asRegex] ifFalse:[stringToSearchFor asRegexIgnoringCase].
   399                     regexPattern := searchIsCaseSensitive 
       
   400                                         ifTrue:[stringToSearchFor asRegex] 
       
   401                                         ifFalse:[stringToSearchFor asRegexIgnoringCase].
   398                     checkFunction := [:s | regexPattern hasMatchesIn:s].
   402                     checkFunction := [:s | regexPattern hasMatchesIn:s].
   399                 ] ifFalse:[
   403                 ] ifFalse:[
   400                     checkFunction :=
   404                     checkFunction :=
   401                         [:s | s includesString:stringToSearchFor caseSensitive:searchIsCaseSensitive]
   405                         [:s | s includesString:stringToSearchFor caseSensitive:searchIsCaseSensitive]
   402                 ]
   406                 ]
   423                         ]
   427                         ]
   424                     ].
   428                     ].
   425             ] ifFalse:[
   429             ] ifFalse:[
   426                 searchForRegexPattern ifTrue:[
   430                 searchForRegexPattern ifTrue:[
   427                     regexPatterns := stringsToSearchFor collect:[:eachPatternString|
   431                     regexPatterns := stringsToSearchFor collect:[:eachPatternString|
   428                                             searchIsCaseSensitive ifTrue:[eachPatternString asRegex] ifFalse:[eachPatternString asRegexIgnoringCase].
   432                                             searchIsCaseSensitive 
       
   433                                                 ifTrue:[eachPatternString asRegex] 
       
   434                                                 ifFalse:[eachPatternString asRegexIgnoringCase].
   429                                         ].
   435                                         ].
   430                     checkFunction := [:s | regexPattern hasMatchesIn:s].
   436                     checkFunction := [:s | regexPattern hasMatchesIn:s].
   431                     checkFunction :=
   437                     checkFunction :=
   432                         [:s |
   438                         [:s |
   433                             regexPatterns perform:combinator with:[:eachRegexPattern |
   439                             regexPatterns perform:combinator with:[:eachRegexPattern |
   477      fn value:'  aaa bb   '.
   483      fn value:'  aaa bb   '.
   478      fn value:'  aaa bbb   '.
   484      fn value:'  aaa bbb   '.
   479     "
   485     "
   480 
   486 
   481     "Created: / 02-05-2019 / 17:32:12 / Claus Gittinger"
   487     "Created: / 02-05-2019 / 17:32:12 / Claus Gittinger"
       
   488     "Modified: / 30-05-2019 / 11:26:26 / Claus Gittinger"
   482 ! !
   489 ! !
   483 
   490 
   484 !StringUtilities class methodsFor:'queries'!
   491 !StringUtilities class methodsFor:'queries'!
   485 
   492 
   486 isUtilityClass
   493 isUtilityClass