javascript - Regex to capture typed information in TypeScript -


I am new to reggax, have taken some tutorials, it is a tough time to get this right.

I am working on language support for type-script for a text editor, and I need a regedx that matches the information of typing in a function. For example:

  function asdf (param1: type1, param2: type2, param3: type3) {...}   

In that, my regex Match 'Type 1', 'Type 2', 'Type 3' etc.

Here's what I'm trying to do:

  \? (??: (\ W).? \)   

Breaks like this:

\ ( look for starting brackets

.

(\ w) Capture group: Next word

\) For brackets to the end of the function parameters Stop it.

Not sure what I'm doing wrong, but like I said I'm new to regx again. At present, it captures the entire stuff, from starting the legs to the feet to close. I need to match only one word after the colon.

Note: I want to make sure that it only matches the words after the calls within the carons so that it can not match the object key / data combos, which < P>

Try this type

  var STRIP_COMMENTS = / ((\\\\\\\\\\\\\\\\\\\\\\\ ************************************************************************** *************************** ARGUMENT_NAMES = / ([^ \ s,] +) / g; Function getParamNames (func) {var fnStr = func.toString (). (STRIP_COMMENTS, '') var results = fnStr.slice change (fnStr.indexOf ('(') + 1, fnStr.indexOf (')')). Match (ARGUMENT_NAMES) if (results === no L) Result = [] for (i = 0; i & lt; result.lamp; i ++) result [i] = result [i] .split (":") [1]; return result}  
  getParamNames ("function asdf (param1: type1, param2: type2, param3: type3) {...}");  



Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -