Javascript Articles - Page 594 of 671

With JavaScript RegExp search a carriage return character.

Ayyan
Updated on 23-Jun-2020 07:45:25

700 Views

To find carriage return character with JavaScript Regular Expression, use the following −\rExampleYou can try to run the following code to find a carriage return character. It returns the position where the carriage return (\r) character is found −           JavaScript Regular Expression                        var myStr = "100% \r Responsive!";          var reg = /\r/;          var match = myStr.search(reg);                    document.write(match);          

How to compare two strings in the current locale with JavaScript?

Shubham Vora
Updated on 17-Aug-2022 08:16:00

611 Views

In this tutorial, we will learn to compare two strings in a current locale with JavaScript. The meaning of the locale is local place or region. Here, we need to compare two strings based on the language of the particular locale. Normally, when users compare the strings using equality or strict equality operators, it doesn’t compare strings based on the current locale. So, we will learn to compare the two strings based on the language of the particular locale. Compare two strings using the localeCompare() Method The String localeCompare() method compares the string with the reference string according to the ... Read More

How to return a new string with a specified number of copies of an existing string with JavaScript?

Prabhdeep Singh
Updated on 07-Nov-2022 06:40:02

258 Views

In this tutorial, we will explore the methods by which we can repeat a string a certain number of times, again and again, to make a new string in JavaScript. There are many scenarios where we may want to make a new string which is just another string repeated ‘x’ number of times and we will see how to achieve that easily using inbuilt methods provided by JavaScript. We want to create a new string which is just another string copied some number of times. Although we can accomplish this task manually by using a for loop or a while ... Read More

With JavaScript Regular Expression find a non-whitespace character.

Daniol Thomas
Updated on 23-Jun-2020 07:49:31

460 Views

To find a non-whitespace character, use the following −\SExampleYou can try to run the following code to find non-whitespace character −        JavaScript Regular Expression                        var myStr = "100% Responsive!";          var reg = /\S/g;          var match = myStr.match(reg);                    document.write(match);          

How to convert Unicode values to characters in JavaScript?

Shubham Vora
Updated on 22-Aug-2022 08:51:03

6K+ Views

In this tutorial, we will learn to convert Unicode values to characters in JavaScript. The Unicode values are the standard values for the character, and users can encode them to convert them into characters. For example, ‘A’ is a Unicode character whose value is 65 according to the ASCII (American standard code for information interchange) table. In the same way, all alphabets, numbers, and other characters have particular Unicode values. We will learn to identify the Unicode character from its values using JavaScript. Using the fromCharCode() Method In JavaScript, the string library contains the fromCharCode() method, which takes the decimal ... Read More

With JavaScript RegExp search a vertical tab character.

Abhinaya
Updated on 23-Jun-2020 07:50:10

279 Views

To find a vertical tab character with JavaScript Regular Expression, use the following −\vExampleYou can try to run the following code to find a vertical tab character. It returns the position where the vertical tab (\v) character is found −           JavaScript Regular Expression                        var myStr = "Secure and \v Responsive!";          var reg = /\v/;          var match = myStr.search(reg);          document.write(match);          

Find the non-digit character with JavaScript Regular Expression

Sravani Alamanda
Updated on 08-Dec-2022 10:26:56

2K+ Views

In this tutorial, we will learn to find the non-digit character with JavaScript regular expression. ASCII code 'A' is 65 and 'a' is 97 etc. Now, we will check how to find a nondigit element (\D) in a given text using RegExp. RegExp is an object that specifies the pattern used to do search and replace operations on string or for input validation. RegExp was introduced in ES1 and it is fully supported by all browsers. Syntax Syntax for the non-digit element is, new RegExp("\D") or simply /\D/ /\D/, is introduced in ES1. It is fully supported by ... Read More

How to check whether a value is a safe integer or not in JavaScript?

Shubham Vora
Updated on 08-Aug-2022 08:59:04

643 Views

In this tutorial, we will learn to check whether a value is a safe integer or not in JavaScript. The simple definition of the safe integer in JavaScript is all numbers we can represent under the IEEE-754 double-precision number. It is the set of all numbers which lie between the -(2^53) to (2^53) exclusive, and we can represent it in the standard way. Here, we have different approaches to checking whether the number is a safe integer. Using the Number.IsSafeInteger() Method Using the if-else Conditional Statement Using the Number.isSafeInteger() Method In JavaScript, the isSafeInteger() method checks that type ... Read More

Set the milliseconds for a specified date according to universal time.

Nishtha Thakur
Updated on 23-Jun-2020 07:38:52

220 Views

Javascript date setUTCMilliseconds() method sets the milliseconds for a specified date according to universal time.The following is the parameter for setUTCMilliseconds(millisecondsValue) −millisecondsValue − A number between 0 and 999, representing the milliseconds.ExampleYou can try to run the following code to set the milliseconds for a specified date according to universal time −           JavaScript setUTCMilliseconds Method                        var dt = new Date( "Aug 28, 2008 23:30:00" );          dt.setUTCMilliseconds( 1200 );                    document.write( dt );          

Find digit with JavaScript RegExp.

Sravani Alamanda
Updated on 26-Aug-2022 13:03:17

940 Views

In this tutorial, we will see how to find digits (0-9) using JavaScript RegExp. ASCII value for digits [0-9] starts from 48 to 57. If you want to print any ASCII value for a digit, 48 needs to be added to that digit. We denote digits as \d in the regular expression. A RegExp is an object that specifies the pattern used to do a search and replace operations on the string or for input validation. Syntax Following is the syntax for regular expression pattern of digit or \d character − new RegExp("\d") or simply /\d/ /\d/ is ... Read More

Advertisements