Found 26504 Articles for Server Side Programming

Golang program to splitting into number of substrings

Akhil Sharma
Updated on 20-Feb-2023 10:12:53

960 Views

In the Go programming language, a substring is a portion of a string that contains a sequence of characters from the original string. A substring can be obtained in Go by using the slicing syntax on a string value.. strings. Split() can be used in Go (Golang) to divide a string into substrings. The first input to the function is the string to be split, and the second argument is the delimiter that will be used to separate the substrings. A slice of strings containing the substrings is the result of the function. There are other ways to split a ... Read More

Golang Program to Check if a string is a valid shuffle of two distinct strings

Akhil Sharma
Updated on 20-Feb-2023 10:11:57

247 Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid Unicode characters. In this article, we will learn how to check if a string is a valid shuffle of two strings using different set of examples. The output will be a Boolean value printed on the console using fmt package. Method: Using a for loop with len method In this method, we will learn how to check if a string is valid shuffle of two distinct strings. This program defines a function ... Read More

Golang program to replace the spaces of string with a specific character

Akhil Sharma
Updated on 20-Feb-2023 10:10:36

2K+ Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid Unicode characters The first and foremost approach used here is Replace() method which replaces the space with a specific character and many more methods can be applied to solve the problem. The modifies string will be the output printed on the console using fmt package. Method 1: Using strings.Replace() function In this method, the space character (" ") is replaced with the character "-" using the Replace() function. The function is instructed ... Read More

Golang Program to divide a string in 'N' equal parts

Akhil Sharma
Updated on 20-Feb-2023 09:55:07

848 Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid UniExample characters. When a string is divided into n equal pieces, n substrings of equal length are created. Using string splitting or string slicing techniques in programming languages, the substrings can be obtained. Let’s see the examples to understand the logic. Method 1: Using for loop and built-in append function In this method, a function called divideString is defined accepts two inputs, a string and an integer, and outputs a slice of ... Read More

Golang program to insert a string into another string

Akhil Sharma
Updated on 20-Feb-2023 10:09:22

2K+ Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid one Example characters. A string is added to or positioned within a bigger string when it is "inserted" into another string. This might be accomplished by replacing a specific substring within the bigger string or at a certain position or index within the larger string. This is frequently used in programming when a string needs to be modified or altered in a particular way, for as by adding a prefix or suffix ... Read More

Golang Program to Lookup enum by String value

Akhil Sharma
Updated on 20-Feb-2023 09:51:33

5K+ Views

In golang, the enumeration constant that corresponds to a given string is necessary to look up an enumeration (enum) by its string value. A switch statement or a string of if-else statements can be used to do this. An alternative method is to use a map, with the enumeration constants serving as the values and the string values acting as the keys. Enumeration constants can now be quickly and effectively looked up using their string form. Let’s find how to lookup enum by string value in go programming language with various example. Method 1: Using string representation In this example ... Read More

Python Program to pass the tuple as function arguments

Harshit Sachan
Updated on 17-Feb-2023 14:34:03

7K+ Views

Tuples are an important data type in Python and are often used to store a fixed set of elements. In this article, we will be discussing how to pass a tuple as function arguments in Python. We will go over the syntax for passing tuple arguments and will provide examples of how to do so. Let us first understand the basics that, we will be needing to begin approaching the problem. The problem asks us to pass a tuple as a function argument, for that we need to know what a function in python is, what are function arguments, ... Read More

Python Program to Merge two Tuples

Harshit Sachan
Updated on 17-Feb-2023 14:29:44

4K+ Views

In Python, tuples are an immutable sequence type that is commonly used to store a collection of items. We can define a tuple in python using the round brackets enclosing the data that we wish to store − Var = (1, ‘a’, 3.7) There are times when we must use a single variable that has the elements of two or more different tuples. In those cases, we must know the ways we can merge them to create a single variable. In this article, we will be discussing how to merge two tuples in Python. Using + ... Read More

Golang Program to convert a string into lowercase

Akhil Sharma
Updated on 17-Feb-2023 15:14:27

2K+ Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid Unicode characters. In this article we will write a go language program to convert a string to lowercase. Method 1: Using User-defined function In this method, we are going to create a user-defined function to convert a given string into lowercase using in go programming language. Algorithm Step 1 − First, we need to import the fmt package. Step 2 − Then, create a function to convert a string to lowercase. ... Read More

Golang Program to trim a string from the left side

Akhil Sharma
Updated on 17-Feb-2023 15:12:38

7K+ Views

In the Go programming language, strings are a built-in data type that represents sequences of characters. They are defined using double quotes (") and can contain any valid Unicode characters. In this article, we will write a go language program to trim a string from the left side. Method 1: Using User-Defined function In this method, we are going to create a user-defined function with for loop to iterate over the string. It will compare the character of the string to the character from the left side to be removed. If they are equal then remove that character from the ... Read More

Advertisements