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

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -