How-to articles, tricks, and solutions about STRING

How to extract numbers from a string in Python?

In Python, you can use regular expressions to extract numbers from a string.

How to extract the substring between two markers?

In Python, you can use the str.find() method to find the index of the first marker, and the str.rfind() method to find the index of the second marker.

How to Format a JavaScript Date

Read the tutorial and find out the methods and libraries used to format the JavaScript date. Find the method you think is best for you and get the codes.

How to Format a Number with Two Decimals in JavaScript

Read this JavaScript tutorial and learn useful information about several easy built-in methods that are used for formatting the number with two decimals.

How to Format Numbers as Currency String

This tutorial provides useful information about the formatting number as currency strings. Read and learn several methods you can use to solve your problem.

How to generate a random alpha-numeric string

To generate a random alpha-numeric string in Java, you can use the Random class and the nextInt and nextBoolean methods to generate random characters and append them to a StringBuilder. Here's an example of how you might do this:

How to get a function name as a string?

In Python, you can use the built-in function attribute __name__ to get the name of a function as a string.

How to get everything after a certain character?

You can use the strstr() function to get everything after a certain character in a string.

How to Get File Extensions with JavaScript

Read this tutorial and learn several useful, fast and simple one-line and extended solutions of extracting file extensions with the help of JavaScript.

How to Get Parameters from a URL String with PHP

Learn how to get the parameters from a URL string in PHP with the help of our short tutorial. Read on and check out the helpful examples below.

How to Get Query String Values in JavaScript

On this page, you can find fast and simple solutions on how to get query string values in JavaScript. Just follow the examples given below to make it work.

How to Get the First Character of a String

Read this JavaScript tutorial and learn several string methods that are used to retrieve the first character of a string. Choose the best one for you.

How to Get the First Several Characters of a String in PHP

On this page, we represent to you the ways of getting the first five characters of a string in PHP. Keep on reading the snippet and check out the examples.

How to Get the Last Characters of a String

Read and learn several easy and simple methods you can use for retrieving the last characters of a JavaScript string. Choose the best method for your case.

How to get the position of a character in Python?

You can use the index() method to get the position of a specific character in a string.

How to get the Query Builder to Output its Raw SQL Query as a String with PHP

If you want to grasp the way of getting a query builder to output its raw SQL query as a string using PHP, then you are in the right place.

How to Get the Value of Selected Option in a Select Box

Read the tutorial and learn the methods of getting the value of the selected option in a select box using jQuery. Read about the text() and val() methods.

How to Get URL Parameters

Read this JavaScript tutorial and learn how you can easily get the URL parameters with the help of the methods provided by the URLSearchParams interface.

How to include a PHP variable inside a MySQL statement

To include a PHP variable inside a MySQL statement, you need to use prepared statements with bound parameters.

How to Loop Through or Enumerate a JavaScript Object

Read this tutorial and learn several useful methods of looping through or enumerate a JavaScript object. Try and copy the piece of the code right away.

How to Measure Script Execution Time in PHP

In this snippet, we demonstrate the simplest way of measuring the execution time of a string in PHP. Read on and check out the examples.

How to nicely format floating numbers to string without unnecessary decimal 0's

To format a floating-point number as a string without unnecessary decimal zeros, you can use the DecimalFormat class from the java.text package. The DecimalFormat class allows you to specify a pattern for formatting numbers as strings.

How to Pass Variables by Reference in PHP

Working with variables is an essential part of a developer’s life. In this snippet, we will demonstrate to you how to pass variables by reference with PHP.

How to read a file line-by-line into a list?

To read a file line-by-line into a list, you can use the following approach:

How to read a text file into a string variable and strip newlines?

In Python, you can read a text file into a string variable and strip newlines using the following code: