博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
通过Lighter.js代码解析正则表达式
阅读量:2519 次
发布时间:2019-05-11

本文共 1535 字,大约阅读时间需要 5 分钟。

Perfecting a regular expression can take a lot of time and testing but once achieved can be a absolutely golden. While looking through the source code of I stumbled upon a few code-parsing regular expressions that you might be interested in.

完善正则表达式可能会花费大量时间和测试,但一旦实现则绝对是黄金。 在浏览的源代码时,我偶然发现了一些您可能感兴趣的代码解析正则表达式。

JavaScript (The JavaScript)

// Matches a C style single-line comment.	slashComments: /(?:^|[^\\])\/\/.*$/gm,		// Matches a Perl style single-line comment.	poundComments: /#.*$/gm,		// Matches a C style multi-line comment.	multiComments: /\/\*[\s\S]*?\*\//gm,		// Matches a string enclosed by single quotes.	aposStrings:   /'[^'\\]*(?:\\.[^'\\]*)*'/gm, 		// Matches a string enclosed by double quotes.	quotedStrings: /"[^"\\]*(?:\\.[^"\\]*)*"/gm, 		// Matches both.	strings:       /'[^'\\]*(?:\\.[^'\\]*)*'|"[^"\\]*(?:\\.[^"\\]*)*"/gm,		// Matches a property: .property style.	properties:    /\.([\w]+)\s*/gi,   		// Matches a method call: .methodName() style.	methodCalls:   /\.([\w]+)\s*\(/gm, 		// Matches a function call: functionName() style.	functionCalls: /\b([\w]+)\s*\(/gm,   		// Matches any of the common brackets.	brackets:      /\{|\}|\(|\)|\[|\]/g, 		// Matches integers, decimals, hexadecimals.	numbers:       /\b((?:(\d+)?\.)?[0-9]+|0x[0-9A-F]+)\b/gi

Regular expressions can look heinous so I apologize to anyone whose brains imploded after looking at the above hieroglyphics text. Have useful regular expressions you use often? Share them!

正则表达式可能看起来令人发指,因此,对上述象形文字阅读后大脑崩溃的人,我深表歉意。 您是否经常使用有用的正则表达式? 分享他们!

翻译自:

转载地址:http://dvpwd.baihongyu.com/

你可能感兴趣的文章
在所选中的物体中取消选中一些物体.txt
查看>>
grid - 网格项目跨行或跨列
查看>>
Shell 基本运算符
查看>>
2019年2月
查看>>
Google Noto Sans CJK 字体
查看>>
ES集群性能调优链接汇总
查看>>
STL库的应用
查看>>
spark算子
查看>>
(转)Linux服务器SNMP常用OID
查看>>
点到平面的距离
查看>>
linux下安装FTP
查看>>
第四周编程总结
查看>>
经典机器学习算法系列7-svd
查看>>
mxnet系列 全连接层代码阅读
查看>>
0715
查看>>
USB各种模式 解释
查看>>
数据访问-----ADO.NET 小结和练习
查看>>
Linux lsof详解
查看>>
子组件给父组件传数据
查看>>
unix/linux下的共享内存、信号量、队列信息管理
查看>>