Sidebar

Home



Expressions V4


Tutorials

How-To

Reference

  Lexical basics
  Type system
  Variables and assignment
  Operators
  Expression rules
  Control flow
  Functions
  Built-in functions
   None and NaN
   Arithmetic
   Algebra
   Logarithmic and Exponential
   Trigonometric
   Rounding and Centering
   Strings
   Output, Formatting, Clipboard, and Errors
   Dialog Functions
   Platform and Paths
  Methods and properties
  Built-in methods
   Common Value Methods
   Number Methods
   String Basic Methods
   String Slice Methods
   String Parsing Methods
   String Formatting Methods
   String Regex Methods
   String Trim and Case Methods
  Objects
  Built-in objects
   Global objects
    settings
    controller
    session
    python
   Collections
    array
    map
    bytes
   File Format I/O
    image_data
    image_stream
   Utils
    crypto
    timer
   Comm
    serial
   Dialogs
    file_open
    file_save
    msg_ok
    msg_ok_cancel
    msg_yes_no
    msg_password
   GUI objects
    window
    panel
    group
    splitpanel
    label
    textbutton
    drawablebutton
    togglebutton
    togglegroup
    textinput
    textedit
    numinput
    slider
    combobox
    listbox
    progressbar
    led
    separator
    menu
    image
    snake
  Classes and user-defined objects
  Include system
  Error model
  Execution model and sessions
  Host integration
  Limits and performance
  Formal reference
  Glossary

Cookbook

exprv4:reference:methods:string_formatting_methods



String Formatting Methods

String formatting methods create derived string values from an existing string.


repeat(count)

Repeats the string.

Argument Type Description
`count` number Number of repetitions. Values less than or equal to zero return an empty string.

Returns: string.

Example:

'ab'.repeat(3);       // 'ababab'

padleft(pad, length)

Pads the string on the left until it reaches the requested length.

Argument Type Description
`pad` any Padding text. Empty padding uses a space.
`length` number Target string length.

Returns: string.

Example:

'7'.padleft('0', 3);  // '007'

padright(pad, length)

Pads the string on the right until it reaches the requested length.

Argument Type Description
`pad` any Padding text. Empty padding uses a space.
`length` number Target string length.

Returns: string.

Example:

'7'.padright('0', 3); // '700'

table()

Formats semicolon-separated text as a table.

Item Description
Syntax `string.table()`
Arguments none
Returns string

Example:

text = 'A;B;C';
text.table();

table(header)

Formats semicolon-separated text as a table, optionally treating the first row as a header.

Argument Type Description
`header` any Converted to bool. True means the first row is treated as a header.

Returns: string.

Example:

text = 'Name;Value\nX;10';
text.table(true);

ord()

Returns the numeric code of the first character.

Item Description
Syntax `string.ord()`
Arguments none
Returns number

An empty string returns `0`.

Example:

'A'.ord();            // 65
''.ord();             // 0

Previous: String Parsing Methods

Next: String Regex Methods

exprv4/reference/methods/string_formatting_methods.txt · Last modified: by 127.0.0.1

Page Tools