Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
12
Task/String-matching/Tcl/string-matching-4.tcl
Normal file
12
Task/String-matching/Tcl/string-matching-4.tcl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
set matchLocations [regexp -indices -all -inline ***=$needle $haystack]
|
||||
# Each match location is a pair, being the index into the string where the needle started
|
||||
# to match and the index where the needle finished matching
|
||||
|
||||
set isContained [expr {[llength $matchLocations] > 0}]
|
||||
set isPrefix [expr {[lindex $matchLocations 0 0] == 0}]
|
||||
set isSuffix [expr {[lindex $matchLocations end 1] == [string length $haystack]-1}]
|
||||
set firstMatchStart [lindex $matchLocations 0 0]
|
||||
puts "Found \"$needle\" in \"$haystack\" at $firstMatchStart"
|
||||
foreach location $matchLocations {
|
||||
puts "needle matched at index [lindex $location 0]"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue