My table name is : table_video My field name in db is : url_value
Whose value is : http://192.168.1.124/test/abcd/abcd.m3u8
Value which is needed by me : http://192.168.1.124/test/abcd_NEW/abcd_NEW.m3u8
There are multiple values in place of "abcd", above url is just one example.
var cursor = db.table_video.find();
while (cursor.hasNext()) {
var x = cursor.next();
print("\n\n-----------------------------------");
print("Before : url_value : "+x['url_value']);
x['url_value'] = x['url_value'].replace(/^(.*?)\/test\/(.*?)\/(.*?)\.m3u8$/g, $1/test/$2_NEW/$2_NEW.m3u8);
print("After : url_value : "+x['url_value']);
db.table_video.update({_id : x._id}, x);
}
When I execute above command in mongo console, it gives an error : 2015-11-28T12:40:08.342+0530 ReferenceError: $1 is not defined
Any help is greatly appreciated