I need to get two parts (username/gistid and filename) from a github gist url.
Sofar i got this:
const gisturl = "https://gist.github.com/vanaf1979/329abed564c2ba10eda29a53b399ac69#file-parse-wp-rest-api-1-parse-js";
const myRegexp = /\.com\/+(.*)?#file-(.*)/gi;
const matches = myRegexp.exec(gisturl);
console.log(matches);
whithc gives me
0: ".com/vanaf1979/329abed564c2ba10eda29a53b399ac69#file-parse-wp-rest-api-1-parse-js"
1: "vanaf1979/329abed564c2ba10eda29a53b399ac69"
2: "parse-wp-rest-api-1-parse-js"
So far so good, except the filename (#file-parse-wp-rest-api-1-parse-js) is optional and if i remove it from the string the regex doest match anymore.
So i need the regex to match both case with or without the filename.
Any help would be very appreciated.