-2

Can you please help to write regex for below current format to expected format.

Current format data:

web_add_auto_header("Origin",  
      "http://eesere6090582.loot.welcome.com:8888");
web_add_auto_header("Wicket-Ajax",  
      "true");
web_add_auto_header("Wicket-Ajax-BaseURL",  
      "servers?1");
web_add_auto_header("Wicket-FocusedElementId",  
      "id40");
web_add_auto_header("X-Requested-With",  
      "XMLHttpRequest");

Expected format:

web_add_auto_header("Origin","http://eesere6090582.loot.welcome.com:8888");
web_add_auto_header("Wicket-Ajax","true");
web_add_auto_header("Wicket-Ajax-BaseURL","servers?1");
web_add_auto_header("Wicket-FocusedElementId","id40");
web_add_auto_header("X-Requested-With","XMLHttpRequest");
karel
  • 5,489
  • 46
  • 45
  • 50

2 Answers2

-1

Assuming the empty space at the start of the strings could be tab(s) or multiple single spaces, .. you're regex could look like :

",\n\s+"   replace with   "\,"

https://regex101.com/r/7J4sC7/1

bertje
  • 45
  • 5
  • is there any way we can add groups like below web_add_auto_header(.*?)",\n\s+","(.*?)); I have to add "Web_add_auto_header in search" because i don't want any other function to get update except which is starting with web_add_auto_header – user3400540 Apr 01 '23 at 14:39
  • Why do you escape coma in replacement string? – markalex Apr 01 '23 at 15:04
-1

Use regex ^(web_add_auto_header.*,)\n\s* with replacement $1.

It will replace newlines after strings beginning with web_add_auto_header.

Here is demo at regex101.

markalex
  • 8,623
  • 2
  • 7
  • 32