Javascript Articles - Page 593 of 671

With JavaScript RegExp how to search a string for text that matches regexp?

Priya Pallavi
Updated on 23-Jun-2020 07:53:50

222 Views

To search a string for a text that matches RegExp, use rhe exec() method in JavaScript. If it finds a match, it returns an array of results; otherwise, it returns null.The following is the parameter −string − The string to be searchedExampleYou can try to run the following code to search a string for text matching RegExp −           JavaScript RegExp exec Method                        var str = "JavaScript is an interesting scripting language";          var re = new RegExp( "script", "g" ); ... Read More

What is availWidth property in JavaScript?

Sharon Christine
Updated on 23-Jun-2020 07:54:22

103 Views

Use the screen.availWidth property to return the width of the user’s screen. The result will be in pixels and the Taskbar feature won’t be included.ExampleYou can try to run the following code to learn how to work with the screen.availWidth property in JavaScript −Live Demo                    document.write("Width of the user’s screen: "+screen.availWidth);          

How to convert a date to a string using current locale's conventions?

Manikanth Mani
Updated on 23-Jun-2020 07:54:51

209 Views

JavaScript date toLocaleString() method converts a date to a string, using the operating system's local conventions.The toLocaleString method relies on the underlying operating system in formatting dates. It converts the date to a string using the formatting convention of the operating system where the script is running. For example, in the United States, the month appears before the date (04/15/98), whereas in Germany the date appears before the month (15.04.98).ExampleYou can try to run the following code to learn how to convert a date to a string using current locale’s conventions −           JavaScript toLocaleString Method ... Read More

With JavaScript RegExp search a hexadecimal number character.

Smita Kapse
Updated on 23-Jun-2020 07:55:32

404 Views

To find a hexadecimal number character with JavaScript Regular Expression, use the following. Add the hexadecimal number here −\xddExampleYou can try to run the following code to find hexadecimal number character. It searches for hexadecimal number 53 i.e. S −           JavaScript Regular Expression                        var myStr = "Secure and Responsive!";          var reg = /\x53/g;          var match = myStr.match(reg);                    document.write(match);          

Match Unicode character specified by the hexadecimal number XXXX.

Alankritha Ammu
Updated on 23-Jun-2020 07:56:14

332 Views

To match a Unicode character specified by the hexadecimal number xxx with JavaScript Regular Expression, use the following −\uxxxxExampleYou can try to run the following code to match the hexadecimal number character xxxx. It matches the hexadecimal number 53 i.e. S −           JavaScript Regular Expression                        var myStr = "Secure and Responsive!";          var reg = /\u0053/g;          var match = myStr.match(reg);                    document.write(match);          

With JavaScript RegExp search an octal number character.

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

306 Views

To find an octal number character with JavaScript Regular Expression, use the following. Add the octal number here − \xxx You can try to run the following code to find an octal number character. It searches for octal number 123 i.e S − Example Live Demo JavaScript Regular Expression var myStr = "Secure and Responsive!"; var reg = /\123/g; var match = myStr.match(reg); document.write(match); Output S

What is the role of pageXOffset property in JavaScript?

Samual Sam
Updated on 23-Jun-2020 07:56:50

258 Views

If you want to get the pixels the document scrolled to from the upper left corner of the window, then use the pageXoffset and pageYoffset property. Use pageXoffset for horizontal pixels.ExampleYou can try to run the following code to learn how to work with pageXOffset property in JavaScript −Live Demo                    div {             background-color: green;             height: 1500px;             width: 1500px;          }                              function scrollFunc() {             window.scrollBy(200, 200);             alert("Horizonal: " + window.pageXOffset);          }             Scroll                      

For the Hosts Locale how to convert a string to uppercase letters in JavaScript?

Shubham Vora
Updated on 15-Nov-2022 08:08:31

322 Views

In this tutorial, we will learn how to convert a string to uppercase letters for the host's locale in JavaScript. While using a locale language to write for a website, we might have to convert the sentence from lowercase to uppercase without changing the structure of the string. Using the toLocaleUpperCase() Method In JavaScript, we use the toUpperCase() Method as well as the toLocaleUpperCase() to change the letters of a string to uppercase. Although both methods give similar output the toLocaleUpperCase() is used primarily for local languages. Syntax We will use the following syntax to convert the letters of the ... Read More

Find a form feed character with JavaScript RegExp.

Sravani Alamanda
Updated on 26-Aug-2022 12:52:29

1K+ Views

Form feed character is page breaking ASCII control character. It is commonly used for page separators. When you want to insert a page break, the text editor can use this form feed. It is defined as \f and has an ASCII code value as 12 or 0x0c. RegExp is an object that specifies the pattern used to do a search and replace operations on a string or for input validation. RegExp was introduced in ES1, and it is fully supported by all browsers. Now, we will check how to find the form feed (\f) character in the given text using ... Read More

For Hosts Locale how to convert a string to lowercase letters in JavaScript?

Lakshmi Srinivas
Updated on 23-Jun-2020 07:46:38

171 Views

To convert a string to lowercase letters in JavaScript, use the toLocaleLowerCase() method.ExampleYou can try to run the following code to learn how to work with toLocaleLowerCase() method in JavaScript −Live Demo                    var a = "WELCOME!";          document.write(a.toLocaleLowerCase());          

Advertisements