ADVERTISEMENT
ADVERTISEMENT

Golang strconv.CanBackquote() Function with Examples

Golang | strconv.CanBackquote() Function: Here, we are going to learn about the CanBackquote() function of the strconv package with its usages, syntax, and examples.
Submitted by IncludeHelp, on September 07, 2021

strconv.CanBackquote()

The CanBackquote() function is an inbuilt function of the strconv package which is used to check whether the given string can be represented unchanged as a single-line backquoted string without control characters other than tab.

It accepts one parameter (s string) and returns true if the string can be represented unchanged as a single-line backquoted; false, otherwise.

Syntax:

func CanBackquote(s string) bool

Parameter(s):

  • s : A string value to be checked.

Return Value:

The return type of the CanBackquote() function is bool, it returns true if the string can be represented unchanged as a single-line backquoted; false, otherwise.

Example 1:

// Golang program to demonstrate the
// example of strconv.CanBackquote() Function

package main

import (
	"fmt"
	"strconv"
)

func main() {
	fmt.Println(strconv.CanBackquote("Hello,there"))
	fmt.Println(strconv.CanBackquote("Hi Buddy ☺"))
	fmt.Println(strconv.CanBackquote(`"Hello,there"`))
	fmt.Println(strconv.CanBackquote(`"Hi Buddy ☺"`))

	fmt.Println("------")
	fmt.Println(strconv.CanBackquote("`Hello,there`"))
	fmt.Println(strconv.CanBackquote("`Hi Buddy ☺`"))
}

Output:

true
true
true
true
------
false
false

Example 2:

// Golang program to demonstrate the
// example of strconv.CanBackquote() Function

package main

import (
	"fmt"
	"strconv"
)

func main() {
	// Checking with tabs
	fmt.Println(strconv.CanBackquote("Hello,there"))
	fmt.Println(strconv.CanBackquote("Hello,there\n"))
	fmt.Println(strconv.CanBackquote("Hello,there\r"))
	fmt.Println(strconv.CanBackquote("Hello,there\a"))
	fmt.Println(strconv.CanBackquote("Hello,there\t"))
}

Output:

true
false
false
false
true

Golang strconv Package »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.