Skip to content
aa1024 edited this page Jun 10, 2018 · 4 revisions

str

String helper functions - flip case, space fill, zero fill, camelcase, uncamelcase, underscore separated, snakecase, startcase, traincase

stc

startcase "an example string" -> "An Example String"

param x: String
q).str.stc"start-case string"

sc

Snakecase : underscore separated text , but the case is preserverd

param x: String
returns: underscore separated text without any case changes.
q).str.sc "An example of Snake case"

tc

Traincase : hyphen separated text , but the case is preserverd

param x: String
returns: hyphen separated text without any case changes.
q).str.tc"An example of Train case"

us

Camel case to lower case underscore separated

param x: String in camel case form or space separated
returns: underscore separated text
q).str.us"spaceSeparated text"

cc

To camel case

param x: String containing underscores, hyphens or spaces
returns: Camel case string
q).str.cc"underscore_separated_text"

ucc

Uncamelcase - Camel case to space separated text , case is preserved

param x: Camel case string
returns: Space separated string
q).str.ucc"addSpaceInCamelCase"

fc

Swap/Flip case

param x: String
returns: String with case swapped
q).str.fc"FlipCase"

sfl

Space fill

param x: int
param y: String
returns: String left padded with space
q).str.sfl (3;12)

sfr

Space fill from right

param x: int
param y: String
returns: String right padded with space
q).str.sfr (3;12)

sflb

Space fill from left for list of strings

param x: int
param y: String
returns: String left padded with space
q).str.sflb (`a`bbb`cc)

sfrb

Space fill from right for list of strings

param x: int
param y: String
returns: String right padded with space
q).str.sfrb (`a`bbb`cc)

zfl

zero fill

param x: int
param y: String
returns: String left padded with zero
q).str.zfl (4;72)

zfr

zero fill from right

param x: int
param y: String
returns: String right padded with zero
q).str.zfr (4;72)

strif

handle the simple case otherwise flaten it to string

param x: String
returns: Converts the kdb objects to plain string
q).str.strif[`test]
q).str.strif[2#`test]
q).str.strif[string `test]
q).str.strif[string 2#`test]
Clone this wiki locally