Get length of a string in Julia – length() Method
The length() is an inbuilt function in julia which is used to return the length of the specified string with desired starting and end position.
Syntax:
length(S::AbstractString)
or
length(S::AbstractString, i::Integer, j::Integer)Parameters:
- S::AbstractString: Specified string
- i::Integer: Inclusive starting position.
- i::Integer: Inclusive ending position.
Returns: It returns the length of the specified string with desired starting and end position.
Example 1:
# Julia program to illustrate # the use of String length() method # Finding the length of the string# "Geeks"println(length("Geeks")) # Finding the length of the string# "Geeks" from 2nd to 4th positionprintln(length("Geeks", 2, 4)) # Finding the length of the string# "Geeks" from 2nd to 5th positionprintln(length("Geeks", 2, 5)) # Finding the length of the string# "GeeksforGeeks" println(length("GeeksforGeeks")) # Finding the length of the string# "GeeksforGeeks" from 2nd to 2nd positionprintln(length("GeeksforGeeks", 2, 2)) # Finding the length of the string# "GeeksforGeeks" from 4th to 10th positionprintln(length("GeeksforGeeks", 4, 10)) |
Output:
Example 2:
# Julia program to illustrate # the use of String length() method # Finding the length of the string# "12345"println(length("12345")) # Finding the length of the string# "12345" from 2nd to 4th positionprintln(length("12345", 2, 4)) # Finding the length of the string# "2468" from 1st to 3rd positionprintln(length("2468", 2, 3)) |
Output:





Please Login to comment...