Home Web Front-end JS Tutorial The replace function replaces individual and global usage methods

The replace function replaces individual and global usage methods

Sep 29, 2017 am 09:51 AM
replace overall situation

//单个
var aa="1-2-3";
aa=aa.replace(',',".");
console.log(aa);
Copy after login

//Global replacement

var aa="1-2-3";
aa=aa.replace(/-/g,".");
console.log(aa);
Copy after login

##//Cut the content in the square bracket characters

var text ="hello [Word]";
var aaa=text.match(/([^\[\]]+)(?=\])/g)
console.log(aaa);
Copy after login

The above is the detailed content of The replace function replaces individual and global usage methods. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement global loading effect in Vue How to implement global loading effect in Vue Jun 11, 2023 am 09:05 AM

In front-end development, we often have a scenario where the user needs to wait for the data to be loaded during interaction with the web page. At this time, there is usually a loading effect displayed to remind the user to wait. In the Vue framework, it is not difficult to implement a global loading effect. Let’s introduce how to implement it. Step 1: Create a Vue plug-in We can create a Vue plug-in named loading, which can be referenced in all Vue instances. In the plug-in, we need to implement the following two methods: s

How to use the REPLACE function to replace a specified part of a string in MySQL How to use the REPLACE function to replace a specified part of a string in MySQL Jul 25, 2023 pm 01:18 PM

MySQL is a commonly used relational database management system that provides a variety of functions to process and operate data. Among them, the REPLACE function is used to replace the specified part of the string. In this article, we will introduce how to use the REPLACE function for string replacement in MySQL and demonstrate its usage through code examples. First, let’s take a look at the syntax of the REPLACE function: REPLACE(str,search_str,replace_str).

What are the string search and replace techniques in Python? What are the string search and replace techniques in Python? Oct 20, 2023 am 11:42 AM

What are the string search and replace techniques in Python? (Specific code example) In Python, strings are a common data type, and we often encounter string search and replace operations in daily programming. This article will introduce some common string search and replacement techniques, accompanied by specific code examples. To find a specific substring in a string, you can use the find() method or index() method of the string. The find() method returns the index of the first occurrence of the substring in the string.

How to implement global Loading effect in Vue How to implement global Loading effect in Vue Nov 07, 2023 am 09:18 AM

How to implement global Loading effects in Vue In Vue development, implementing global Loading effects is a common requirement. The global Loading effect can give users a good prompt to let them know that the page is loading, improving the user experience. This article will introduce how to implement global Loading effects in Vue and provide specific code examples. Create a global Loading component First, we need to create a global Loading component. This component can be a simple

Use the replace() method of the StringBuilder class in Java to replace part of the content in a string Use the replace() method of the StringBuilder class in Java to replace part of the content in a string Jul 24, 2023 pm 10:28 PM

In Java, use the replace() method of the StringBuilder class to replace part of the content in a string. In Java programming, strings are a very important data type, and strings often need to be processed and manipulated. And sometimes we need to replace part of the string to meet our needs. In Java, you can use the replace() method of the StringBuilder class to implement string replacement operations. StringBuilder is a

Understand HTML global attributes. What are non-global attributes? Understand HTML global attributes. What are non-global attributes? Feb 19, 2024 pm 12:43 PM

Master the global attributes of HTML and understand the importance of non-global attributes. HTML is a markup language used to describe the structure and content of web pages. Its flexibility and ease of use make it an indispensable part of web development. In HTML, there are many global attributes that can be applied to different HTML elements. These attributes can be used throughout the web page, providing a common way to control the behavior and appearance of the element. However, there are also special properties that are not global properties and have specific scope and limitations. Got it

List of Golang flow control statements: Let your program control the overall situation! List of Golang flow control statements: Let your program control the overall situation! Feb 20, 2024 pm 06:09 PM

Title: Overview of Golang flow control statements: let your program control the overall situation! In the Go language, flow control statements are an integral part of writing programs. By flexibly using flow control statements, we can allow the program to execute different logic according to different conditions, achieving more flexible and powerful program functions. This article will delve into the flow control statements in Golang and give you a comprehensive understanding of the usage and functions of these statements. 1. Conditional statement 1.1if statement The if statement is the most basic conditional statement. It depends on the true or false condition of the condition.

Which attributes are not HTML global attributes? Which attributes are not HTML global attributes? Feb 19, 2024 pm 03:16 PM

HTML global attributes are a set of attributes that apply to all HTML elements and can be used by any HTML element. However, not every attribute applies to all elements, and some attributes do not apply to all elements. Below we'll cover some HTML global attributes that don't apply to all elements. accept: This attribute is used for elements to specify acceptable file types. alt: This attribute is used for

See all articles