Geeks With Blogs

News
AngelEyes on .Net Tips, tricks and WTFs about Asp .Net, SQL Server and the likes.
Having dabbled a bit with React / Redux, and while doing so used both the Import statement from ES6 and the Require function of Browserify, I decided I needed a RegEx to replace all "require" lines to "import" lines.
This is what I came up wit, so far:

const\s+(\w+)\s+=\s+require\('([^']+)'\);?

and replace  with;

import $1 from '$2';
Posted on Monday, November 23, 2015 1:15 PM RegEx , JavaScript | Back to top


Comments on this post: (JS) Regular Expression to replace "require" statements with "import statements"

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © AngelEyes | Powered by: GeeksWithBlogs.net