म
MarathiCodeby Sprout Tech
Documentation topicsStrings
MarathiCode v0.2.0

Strings

मजकूर

Strings are written in double quotes and can contain Marathi, English or any other text.

strings.mr
चल नाव = "अमित"
छापा("नमस्कार, " + नाव)
Output (आउटपुट)
नमस्कार, अमित

Escape sequences

WriteTo get
\na line break
\ta tab
\"a double quote
\\a backslash
escapes.mr
छापा("पहिली ओळ\nदुसरी ओळ")
छापा("तो म्हणाला, \"हो\"")
Output (आउटपुट)
पहिली ओळ
दुसरी ओळ
तो म्हणाला, "हो"

Any other backslash sequence is kept exactly as written.

Joining with +

If either side of + is a string, the other side is converted to text and the two are joined. Booleans become खरे / खोटे:

join.mr
चल वय = 18
छापा("वय: " + वय)
छापा("उत्तीर्ण: " + खरे)
Output (आउटपुट)
वय: 18
उत्तीर्ण: खरे

Length, indexing and comparison

  • लांबी(s) gives the length in Unicode code points.
  • s[i] gives the character at position i (starting at 0).
  • <, >, <=, >= compare strings character by character, by Unicode code point.
  • Strings cannot be changed in place: s[0] = "x" is an error.
string_ops.mr
चल शब्द = "abc"
छापा(लांबी(शब्द))
छापा(शब्द[0])
छापा("अ" < "ब")
Output (आउटपुट)
3
a
खरे