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
Post a Comment