Home > Enterprise >  KDB: generate random string
KDB: generate random string

Time:03-05

How can one generate a random string of a given length in KDB? The string should be composed of both upper and lower case alphabet characters as well as digits, and the first character can not be a digit.

Example:

"i0J2Jx3qa" / OK
"30J2Jx3qa" / bad

Thank you very much for your help!

CodePudding user response:

stringLength: 13
randomString: (1 ? .Q.A,.Q.a) , ((stringLength-1) ? .Q.nA,.Q.a)

CodePudding user response:

For the purposes of creating random data you can also use ?/deal with a number of characters up to 8 as a symbol(which you could string). This doesn't include numbers though so just an alternative approach to your own answer.

1?`8
,`bghgobnj
  • Related