I am very, very n00b in regular expression, I'm trying to learn but no success :).
So I have the following file name: myFile.8.9.6-x64.txt
or myFile.8.9.6-x86.txt
So, I want to create a regular expression in order to match x64
or x86
string in file name with:
var regexp = new RegExp(/[x_X][8][6]|[x][6][4]$/);
console.log(regexp.test("myFile.8.9.6-x64.txt")); //returns false instead of true
So, where is my mistake ?
You can actually use this regex:
var regexp = /x(?:86|64)\./i;
new RegExp
takes a string actually not a regex with delimiters as shown in your question $
after 64/86
but your file names are not ending with 64/86
. x
/i
for ignore case matching
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.