- Clojure Tutorial
- Clojure - Home
- Clojure - Overview
- Clojure - Environment
- Clojure - Basic Syntax
- Clojure - REPL
- Clojure - Data Types
- Clojure - Variables
- Clojure - Operators
- Clojure - Loops
- Clojure - Decision Making
- Clojure - Functions
- Clojure - Numbers
- Clojure - Recursion
- Clojure - File I/O
- Clojure - Strings
- Clojure - Lists
- Clojure - Sets
- Clojure - Vectors
- Clojure - Maps
- Clojure - Namespaces
- Clojure - Exception Handling
- Clojure - Sequences
- Clojure - Regular Expressions
- Clojure - Predicates
- Clojure - Destructuring
- Clojure - Date & Time
- Clojure - Atoms
- Clojure - Metadata
- Clojure - StructMaps
- Clojure - Agents
- Clojure - Watchers
- Clojure - Macros
- Clojure - Reference Values
- Clojure - Databases
- Clojure - Java Interface
- Clojure - Concurrent Programming
- Clojure - Applications
- Clojure - Automated Testing
- Clojure - Libraries
- Clojure Useful Resources
- Clojure - Quick Guide
- Clojure - Useful Resources
- Clojure - Discussion
Clojure - Strings subs
Returns the substring of ‘s’ beginning at start inclusive, and ending at end (defaults to length of string), exclusive.
Syntax
Following is the syntax.
(subs s start end)
Parameters − ‘S’ is the input string. ‘Start’ is the index position where to start the substring from. ‘End’ is the index position where to end the substring.
Return Value − The substring.
Example
Following is an example of the string formatting in Clojure.
(ns clojure.examples.hello (:gen-class)) (defn hello-world [] (println (subs "HelloWorld" 2 5)) (println (subs "HelloWorld" 5 7))) (hello-world)
Output
The above program produces the following output.
llo Wo
clojure_strings.htm
Advertisements