Remove a single trailing newline from a string in Julia – chomp() Method
Last Updated :
26 Mar, 2020
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:
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:
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
Share your thoughts in the comments
Please Login to comment...