substring.asciidoc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. [discrete]
  2. [[esql-substring]]
  3. === `SUBSTRING`
  4. Returns a substring of a string, specified by a start position and an optional
  5. length. This example returns the first three characters of every last name:
  6. [source.merge.styled,esql]
  7. ----
  8. include::{esql-specs}/docs.csv-spec[tag=substring]
  9. ----
  10. [%header.monospaced.styled,format=dsv,separator=|]
  11. |===
  12. include::{esql-specs}/docs.csv-spec[tag=substring-result]
  13. |===
  14. A negative start position is interpreted as being relative to the end of the
  15. string. This example returns the last three characters of of every last name:
  16. [source.merge.styled,esql]
  17. ----
  18. include::{esql-specs}/docs.csv-spec[tag=substringEnd]
  19. ----
  20. [%header.monospaced.styled,format=dsv,separator=|]
  21. |===
  22. include::{esql-specs}/docs.csv-spec[tag=substringEnd-result]
  23. |===
  24. If length is omitted, substring returns the remainder of the string. This
  25. example returns all characters except for the first:
  26. [source.merge.styled,esql]
  27. ----
  28. include::{esql-specs}/docs.csv-spec[tag=substringRemainder]
  29. ----
  30. [%header.monospaced.styled,format=dsv,separator=|]
  31. |===
  32. include::{esql-specs}/docs.csv-spec[tag=substringRemainder-result]
  33. |===