'' this is a "test' there is another "test' 第二种情况 /\b'/ Regex Demo-6ren">
cuốn sách gpt4 ai đã làm

javascript - 正则表达式匹配双引号内的单引号(单独)?

In lại Tác giả: Walker 123 更新时间:2023-11-28 12:26:40 28 4
mua khóa gpt4 Nike

如何编写正则表达式来匹配它(参见箭头):

"this is a ->'<-test'" // note they are quotes surrounding a word

还有其他匹配的吗?

"this is a 'test->'<-"

在 JavaScript 中? (然后,比如说,用双引号替换它们?)

我想用两个正则表达式分别匹配它们。

câu trả lời hay nhất

第一种情况

/'\b/

Regex Demo

"this is a 'test' there is another 'test'".replace(/'\b/g, '"'))
=> this is a "test' there is another "test'

第二种情况

/\b'/

Regex Demo

"this is a 'test' there is another 'test'".replace(/\b'/g, '"'))
=> this is a 'test" there is another 'test"

关于javascript - 正则表达式匹配双引号内的单引号(单独)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27775787/

28 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress