Skip to main content

$lineCount

The $lineCount operator counts the number of lines in a string.

Input

  • A single string value

Output

  • The number of lines in the input string (counting newline characters)

Examples

Count Lines in Multi-line String

{
  "$lineCount": [
    "Line 1\nLine 2\nLine 3"
  ]
}
Result: 3

Count Lines in Single Line

{
  "$lineCount": [
    "Single line"
  ]
}
Result: 1

Count Lines in Empty String

{
  "$lineCount": [
    ""
  ]
}
Result: 0

Field Value

{
  "$lineCount": [
    {
      "$input": "content"
    }
  ]
}
Result: The number of lines in the content field