Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/String-matching/Nim/string-matching.nim
Normal file
15
Task/String-matching/Nim/string-matching.nim
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import strutils
|
||||
|
||||
let s = "The quick brown fox"
|
||||
if s.startsWith("The quick"):
|
||||
echo "Starts with “The quick”."
|
||||
if s.endsWith("brown Fox"):
|
||||
echo "Ends with “brown fox”."
|
||||
if s.contains(" brown "):
|
||||
echo "Contains “ brown ”."
|
||||
if "quick" in s:
|
||||
echo "Contains “quick”." # Alternate form for "contains".
|
||||
|
||||
let pos = find(s, " brown ") # -1 if not found.
|
||||
if pos >= 0:
|
||||
echo "“ brown ” is located at position: " & $pos
|
||||
Loading…
Add table
Add a link
Reference in a new issue