龙空技术网

JavaScript——正则 点元字符和空格的使用

北漂佳佳的生活 109

前言:

现时大家对“html中的空格”大约比较注意,同学们都想要了解一些“html中的空格”的相关资讯。那么小编同时在网上汇集了一些有关“html中的空格””的相关资讯,希望朋友们能喜欢,咱们一起来了解一下吧!

let str = "jiajia2023_&^%^&";console.log(str.match(/.+/));//匹配除换行符以外的任何单个字符let url = ';console.log(url.match(/https?:\/\/w+\.\w+\.\w+/));//[';, index: 0, input: ';, groups: undefined]// 不能匹配换行符let aStr = `sfjsjalsjkajjnjndgudjg`;console.log(aStr.match(/.+/));//['sfjsjalsjkajjnjn', index: 1, input: '\nsfjsjalsjkajjnjn\ndgudjg\n', groups: undefined]console.log(aStr.match(/.+/s));//s视为单行  ['\nsfjsjalsjkajjnjn\ndgudjg\n', index: 0, input: '\nsfjsjalsjkajjnjn\ndgudjg\n', groups: undefined]let tel = '010 - 4561237'console.log(tel.match(/\d+ - \d{7}/));//['010 - 4561237', index: 0, input: '010 - 4561237', groups: undefined]console.log(tel.match(/\d+\s-\s\d{7}/));//结果同上,可以用空格,也可以用\s

标签: #html中的空格