Write a JavaScript function that finds all variable names in a given string. A variable name starts with an underscore (“_”) and contains only Capital and Non-Capital English Alphabet letters and digits. Extract only their names, without the underscore. Try to do this only with regular expressions.
The input comes as single string, on which you have to perform the matching.
Examples:
Input:
The _id and _age variables are both integers.
Output:
id,age
Input:
Calculate the _area of the _perfectRectangle object.
Output:
area,perfectRectangle
Input:
__invalidVariable _evenMoreInvalidVariable_ _validVariable
Output:
validVariable
The output consists of all variable names, extracted and printed on a single line, each separated by a comma.