The chomp()
is an inbuilt function in julia which is used to remove a single trailing newline from a string.
Syntax:
chomp(s::AbstractString)Parameters:
- s::AbstractString: Specified string.
Returns: It returns a new string after removal of a single trailing newline.
Example 1:
# Julia program to illustrate # the use of String chomp() method # Getting the removal part of the strings println(chomp( "GFG\n" ))
println(chomp( "Geeks\n\n" ))
println(chomp( "Geeks\nforGeeks" ))
println(chomp( "GFG\ngfg\n" ))
|
Output:
GFG Geeks Geeks forGeeks GFG gfg
Example 2:
# Julia program to illustrate # the use of String chomp() method # Getting the removal part of the strings println(chomp( "1 + 2+3\n" ))
println(chomp( "1 + 2+3\n\n" ))
println(chomp( "1 + 2+3\n4 + 5+6" ))
println(chomp( "1 * 2\n\n3 * 4\n" ))
|
Output:
1+2+3 1+2+3 1+2+3 4+5+6 1*2 3*4
Article Tags :
Recommended Articles