Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* 2025/26/2
* archívum


Linkek

* kalendárium
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C#
* D lang.
* Java
* Nim
* Nim2
  + exercises
* XC=BASIC
* old
  ◇C++, ◇Clojure, ◇Scala


[ edit | logout ]
[ sandbox | passwd ]

Common string methods

find()
s = "joker"

print(s.find("ke"))  # 2

print(s.find("xxx"))  # -1
import std/strutils

let s = "joker"

echo s.find("ke")    # 2

echo s.find("xxx")    # -1
toLowerAscii(), toUpperAscii()
print('a'.upper())  # A

print('A'.lower())  # a

print("adam".upper())  # ADAM

print("LASZLO".lower())  # laszlo
import std/strutils    # strip, split, join


echo 'a'.toUpperAscii()   # A

echo 'A'.toLowerAscii()   # a

echo "adam".toUpperAscii()   # ADAM

echo "LASZLO".toLowerAscii()   # laszlo

𝥶More details here.

toLower(), toUpper()
print('á'.upper())  # Á

print('É'.lower())  # é

print("ádám".upper())  # ÁDÁM

print("LÁSZLÓ".lower())  # lászló
import std/unicode    # Rune


echo "á".toUpper()   # Á

echo "É".toLower()   # é

echo "ádám".toUpper()   # ÁDÁM

echo "LÁSZLÓ".toLower()   # lászló

let
  c: Rune = "á".runeAt(0)
  d: Rune = "É".runeAt(0)

echo c.toUpper()   # Á

echo d.toLower()   # é

𝥶More details here.

startsWith(), endsWith()
s = "https://example.com/01.png"

print(s.startswith("https://"))  # True

print(s.endswith(".png"))  # True
import std/strutils

let s = "https://example.com/01.png"

echo s.startsWith("https://")   # true

echo s.endsWith(".png")         # true
replace()
s = "cat dog cat cat"

print(s.replace("cat", "kitten"))
# kitten dog kitten kitten
import std/strutils

let s = "cat dog cat cat"

echo s.replace("cat", "kitten")
# kitten dog kitten kitten
split()
line = "10:bob:/home/bob"

print(line.split(":"))  # ['10', 'bob', '/home/bob']

########

s = "aa   bb\t\tcc"

print(s.split(" "))  # ['aa', '', '', 'bb\t\tcc']

# use this:
print(s.split())  # ['aa', 'bb', 'cc']
import std/strutils

let line = "10:bob:/home/bob"

echo line.split(":")  # @["10", "bob", "/home/bob"]

# #######

let s = "aa   bb\t\tcc"

echo s.split()   # @["aa", "", "", "bb", "", "cc"]

# use this:
echo s.splitWhitespace()   # @["aa", "bb", "cc"]
join()
li = ["aa", "bb", "cc"]

print(":".join(li))  # aa:bb:cc

primes = [2, 3, 5, 7]

print(" -> ".join([str(n) for n in primes]))
# 2 -> 3 -> 5 -> 7
import std/strutils

let li = @["aa", "bb", "cc"]

echo li.join(":")    # aa:bb:cc

let primes = @[2, 3, 5, 7]

echo primes.join(" -> ")
# 2 -> 3 -> 5 -> 7

𝥶Notice that in Nim, you can join any type of seq. Nim will apply the `$` operator on each element of the seq.

Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2026 April 27, 22:45