Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
50
Task/String-matching/XProfan/string-matching.xprofan
Normal file
50
Task/String-matching/XProfan/string-matching.xprofan
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// XProfan can use StringParts, so the results here
|
||||
// are the comma separated positions of the parts or 0
|
||||
Proc Contains
|
||||
Parameters string content, part
|
||||
var string results = "0"
|
||||
var long posi = 1
|
||||
posi = InStr(part,content,posi)
|
||||
if posi <> 0
|
||||
results = str$(posi)
|
||||
repeat
|
||||
posi = InStr(part,content,posi+1)
|
||||
case posi <> 0 : results = results + "," + str$(posi)
|
||||
until posi == 0
|
||||
endif
|
||||
Return results
|
||||
EndProc
|
||||
|
||||
Proc StartsWith
|
||||
Parameters string content, part
|
||||
Return if(Left$(content,Len(part)) == part, 1, 0)
|
||||
EndProc
|
||||
|
||||
Proc EndsWith
|
||||
Parameters string content, part
|
||||
Return if(Right$(content,Len(part)) == part, 1, 0)
|
||||
'Return if(Left$(content,Len(content)-Len(part)+1) == part, 1, 0)
|
||||
EndProc
|
||||
|
||||
var string theContent = "foobar"
|
||||
var string thePart = "foo"
|
||||
Print "Starts with: "
|
||||
Print " ("+thePart+" in "+theContent+") "+if(StartsWith(theContent,thePart),"Yes","No")
|
||||
thePart = "back"
|
||||
Print " ("+thePart+" in "+theContent+") "+if(StartsWith(theContent,thePart),"Yes","No")
|
||||
|
||||
theContent = "foooooobar"
|
||||
Print "Contains: "
|
||||
Print " ("+thePart+" in "+theContent+") "+ Contains(theContent,thePart)
|
||||
thePart = "o"
|
||||
Print " ("+thePart+" in "+theContent+") "+ Contains(theContent,thePart)
|
||||
|
||||
theContent = "foobar"
|
||||
thePart = "back"
|
||||
Print "Ends with: "
|
||||
Print " ("+thePart+" in "+theContent+") "+if(EndsWith(theContent,thePart),"Yes","No")
|
||||
thePart = "bar"
|
||||
Print " ("+thePart+" in "+theContent+") "+if(EndsWith(theContent,thePart),"Yes","No")
|
||||
|
||||
waitkey
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue