
- Erlang Tutorial
- Erlang - Home
- Erlang - Overview
- Erlang - Environment
- Erlang - Basic Syntax
- Erlang - Shell
- Erlang - Data Types
- Erlang - Variables
- Erlang - Operators
- Erlang - Loops
- Erlang - Decision Making
- Erlang - Functions
- Erlang - Modules
- Erlang - Recursion
- Erlang - Numbers
- Erlang - Strings
- Erlang - Lists
- Erlang - File I/O
- Erlang - Atoms
- Erlang - Maps
- Erlang - Tuples
- Erlang - Records
- Erlang - Exceptions
- Erlang - Macros
- Erlang - Header Files
- Erlang - Preprocessors
- Erlang - Pattern Matching
- Erlang - Guards
- Erlang - BIFS
- Erlang - Binaries
- Erlang - Funs
- Erlang - Processes
- Erlang - Emails
- Erlang - Databases
- Erlang - Ports
- Erlang - Distributed Programming
- Erlang - OTP
- Erlang - Concurrency
- Erlang - Performance
- Erlang - Drivers
- Erlang - Web Programming
- Erlang Useful Resources
- Erlang - Quick Guide
- Erlang - Useful Resources
- Erlang - Discussion
Erlang - substr
The method returns the sub string from the original string based on the starting position and number of characters from the starting position.
Syntax
substr(str1,start,number)
Parameters
str1 − This is the string from which the sub string needs to be extracted.
Start − This is the starting position from where the sub string should start.
Number − This is the number of characters which need to be present in the substring.
Return Value
Returns the sub string from the original string based on the start position and the number.
For example
-module(helloworld). -import(string,[substr/3]). -export([start/0]). start() -> Str1 = "hello World", Str2 = substr(Str1,2,5), io:fwrite("~p~n",[Str2]).
Output
When we run the above program, we will get the following result.
“ello”
erlang_strings.htm
Advertisements