CJex / regulex

:construction: Regular Expression Excited!
https://jex.im/regulex/
MIT License
5.71k stars 756 forks source link

Named capture groups ? #5

Closed gilou closed 9 years ago

gilou commented 9 years ago

Hey, nice tool, I might use that to help others understand regexp better ;)

However, it seems your script doesn't handle named capture groups : Python's (?P<name1>xxx) to be refered as (?P=name1) or Perl's (?<name1>) => \k<name1>

Might be fun to add to your parser...

furier commented 9 years ago
Error:Unexpected char!

^(?<Date>\d{4}-\d{1,2}-\d{1,2})\s+(?<Time>\d{2}:\d{2}:\d{2}),?\d{3}\s+(?<LogLevel>INFO|DEBUG|WARN|ERROR|FATAL)\s+(?<PID>\d+)\s+(?<Logger>[a-zA-Z.]*)\s+-?\s+(?:(?<Memory>\[MEMORY:\s\d+,?\d+\w+\])\s+(?<TcpConnections>\[TCP CONNECTIONS:\s\d+,?\d+\])\s)?(?<Message>.*)$
--^

No cant handle named capture groups...

CJex commented 9 years ago

At present this tool focuses on JavaScript RegExp syntax, not PCRE. JavaScript RegExp doesn't support named capture groups.

I had consider implementing this feature,but because this tool's goal is conforming with 《ECMAScript Standard》 ,and which syntax to support is a problem,Python or PCRE or XRegExp?

Any more suggestions?

gilou commented 9 years ago

Ah, I didn't think about the ECMAScript by default, even though it makes sense for a .js.. ;) Well, PCRE integrated Python's notation (and .NET's) hehe, see http://pcre.org/pcre.txt

CJex commented 9 years ago

Merge with: https://github.com/JexCheng/regulex/issues/16

liudongmiao commented 2 years ago

demo: https://jianyu.io/regulex/