简体   繁体   中英

How to convert this in a JavaScript Code

I'm very new on this and I isn't a pro on this issues!

I'm just here for request for your help because I know this community is the best for this problems!

Actually I'm using a software called "Bulk Rename Utility", it works for bulk rename files with a very useful interface, one of them is the RegEx option where you can rename files thanks to the regular expresion lenguage.

I was wonder if I can convert this code in a JavaScript code, this is because I need to modify various parameters and it could be better if I can use a JavaScript code.

As I told you, I'm very new on this. After checking some videos I learned how to use the RegEx option in this program and the codes I got was:

In the "Match" field of the program I write: (.*) 10-1[AZ] (.*) .

In the "Replace" filed of the program I write: \\1_REF_\\2

A then, it do the magic!

As I said, I want to know how I can convert this code to a JavaScript code because I have a lot of this codes and I want just one whole code to make a bulk process.

Thanks you so much!

Like this?

 const str = 'abc 10-1G def'; const outputStr = str.replace(/(.*) 10-1[AZ] (.*)/, '$1REF$2'); console.log(outputStr); 

You just need to put $1 / $2 in place of the captured groups you want in the replaced string.

To insert code, you can put the code between backticks (`) and you'll be able to type *s normally.

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