2

Hi I got about a 1000 lines of data, what I need to do is using regular expression mode on visual code to find "),(" and replace with a new line after the comment. Is this possible, below is an example of what im trying to achieve.

(test, null, null, 1),(test1, null, null, 2)

into

(test, null, null, 1),
(test1, null, null, 2)
4
  • @JamesThorpe, yes this is correct Commented Feb 21, 2017 at 12:16
  • Do you even need regex for that? Would have thought the bog-standard find/replace should just find ),( without issue Commented Feb 21, 2017 at 12:17
  • How would you implement the new line @JamesThorpe Commented Feb 21, 2017 at 12:21
  • Sorry, yes - was forgetting you needed that mode turned on to do more complex replace statements - was concentrating on the find part :) Commented Feb 21, 2017 at 12:24

1 Answer 1

6

Search:

\([^\)]*\),

\(, \) and , are literals

[^\)]* matches all characters which are not an )

Replace:

$0\n

$0 is the back reference for the whole match

$x (e.g. $1) would be the back reference for a group marked by ( and ), but is not required here as kennytm pointed out

\n is a newline

Sign up to request clarification or add additional context in comments.

1 Comment

You could use $0 to refer to the whole match, thus no need to add the capturing group (…).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.