substring.asciidoc 1.1 KB

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