简体   繁体   中英

Node.js pattern matching logic

I am new to node.js and I have a requirement where I need to read txt file where I need to match different patterns in it. So, lets say it has A~B~C which should match with *!B!C. Any help is much appreciated. Thanks

Performance issues aside, you can use regular expressions in javascript to do that kind of text pattern matching. MDN has a pretty good overview: MDN Regular Expressions Guide

If you're new to regexes or need to brush up, I also found this site to be extremely helpful. http://www.regular-expressions.info/tutorial.html

Be aware that there are a few JavaScript-specific formatting issues to know about. That site also covers those.

I have seen others recommend using a character buffer instead of a string object if performance becomes a constraint. Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM