This is the format of the string:
I want to extract the Revision number from the name. I tried using Substring() but I need a generic solution that could extract out Revision number from any name in this format. This is how the name is being set is the backend:
Thanks in advance.
CodePudding user response:
You can try this
const [,revisionNumber] = value.match(/Revision (\d)/)
CodePudding user response:
You could use a regex with a capturing group like this:
const input = 'Access2 - changed - (Revision 2)';
const regex = /^.*\(\w \s(\d )\)$/;
const [, revision] = regex.exec(input);
console.log(revision);