javascript - Replacing string around a number -


i have text file in want following replacements:

"type": "sql.nvarchar(100)", 

with

"type": sql.nvarchar(100), 

the number inside nvarchar can anything. can complete following regex number remains such:

schema = schema.replace(/"sql\.nvarchar(/g, 'sql.nvarchar('); // incomplete 

you can use capturing group capture number, , use in replacement string.

schema = schema.replace(/"sql\.nvarchar\((\d+)\)"/g, 'sql.nvarchar($1)'); //                                     ^^^^^^^^^                   ^^ 

in regular expression, \d+ inside parentheses captured , used in replacement.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -