javascript - 正则表达式,如何分组?地址和标题分一组
<code>http://s.click.taobao.com/t?e=m%3D2%26s%3DC1Wj%2FDUvnQAcQipKwQzePOeEDrYVVa64REOHN%2B0iJT23bLqV5UHdqcvC2rKjuw6htYQMu9Tydq0qC%2FWAES3KjEVAR5FF1Zuf0M83nhvB7wsgfuBp9F3RPL6hW3GYyufa0nk1uZWo%2BVgFCjfdoeI9bCSQFfUF8UG8x1IYFu75azTnWUvVnK10NV9FS%2FIENZ7iyNYJBoTNJ8s%3D 创意男女雨伞长柄伞晴雨伞双人伞超大拍下19.8元包邮 http://s.click.taobao.com/t?e=m%3D2%26s%3D7hgtkzLk%2FnkcQipKwQzePOeEDrYVVa64qu1K02Mshg63bLqV5UHdqcvC2rKjuw6h0e71iVTN2RwqC%2FWAES3KjEVAR5FF1Zuf0M83nhvB7wsgfuBp9F3RPP0sHo1DWd7dVEdXKgUyOXuT1UqJ0PWIzMZOr18RYav6TWOYZ4V%2FN1d%2FC3KL%2B7ueeV1VbYMvpJWxTM78ni%2FxOXSiZ%2BQMlGz6FQ%3D%3D 佳诺仰卧板仰卧起坐健身器材仅78元起包邮 </code>
上面的文本,如何变成2组,每组包括地址和标题?
我用下面的正则匹配出了5组搞了半天没搞出来
回复内容:
<code>http://s.click.taobao.com/t?e=m%3D2%26s%3DC1Wj%2FDUvnQAcQipKwQzePOeEDrYVVa64REOHN%2B0iJT23bLqV5UHdqcvC2rKjuw6htYQMu9Tydq0qC%2FWAES3KjEVAR5FF1Zuf0M83nhvB7wsgfuBp9F3RPL6hW3GYyufa0nk1uZWo%2BVgFCjfdoeI9bCSQFfUF8UG8x1IYFu75azTnWUvVnK10NV9FS%2FIENZ7iyNYJBoTNJ8s%3D 创意男女雨伞长柄伞晴雨伞双人伞超大拍下19.8元包邮 http://s.click.taobao.com/t?e=m%3D2%26s%3D7hgtkzLk%2FnkcQipKwQzePOeEDrYVVa64qu1K02Mshg63bLqV5UHdqcvC2rKjuw6h0e71iVTN2RwqC%2FWAES3KjEVAR5FF1Zuf0M83nhvB7wsgfuBp9F3RPP0sHo1DWd7dVEdXKgUyOXuT1UqJ0PWIzMZOr18RYav6TWOYZ4V%2FN1d%2FC3KL%2B7ueeV1VbYMvpJWxTM78ni%2FxOXSiZ%2BQMlGz6FQ%3D%3D 佳诺仰卧板仰卧起坐健身器材仅78元起包邮 </code>
上面的文本,如何变成2组,每组包括地址和标题?
我用下面的正则匹配出了5组搞了半天没搞出来
先把最后的"\n"
去掉啊,不过既然是分行的,干嘛不s.split("\n")
?
就这样分组就行,但是要遍历析取,每次取出两组,用javascript实现:
var str = 'http://s.click.taobao.co/t?e=m=2...', matchArr, REGEX = /(.*)([\u4e00-u9fa5]*)\n?/g; while ((matchArr = REGEX.exec(str))) { var address = matchArr[1], title = matchArr[2]; console.log(address); //http://s.click.taobao.com/t?e=m=2... console.log(title); //创意男女雨伞长柄伞... }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Regarding the problem of removing the Python interpreter that comes with Linux systems, many Linux distributions will preinstall the Python interpreter when installed, and it does not use the package manager...

Pylance type detection problem solution when using custom decorator In Python programming, decorator is a powerful tool that can be used to add rows...

About Pythonasyncio...

Using python in Linux terminal...

Loading pickle file in Python 3.6 environment error: ModuleNotFoundError:Nomodulenamed...

Error loading Pickle file in Python 3.6 environment: ModuleNotFoundError:Nomodulenamed...

The problem and solution of the child process continuing to run when using signals to kill the parent process. In Python programming, after killing the parent process through signals, the child process still...

How to use Pandas to implement column-to-column statistics of data? In data analysis, you often encounter situations where data needs to be reorganized and counted. For example, there is a...
