2

My objective

This question is about Visual Studio Code search box.

I want to replace all the "spaces" by the character "_" inside the my substring with spaces of mystring

for example:

-> From

{
    "Show_details": mystring("my substring with spaces"),
    "Type_of_event": mystring("my substring with spaces2"),
}

-> To

{
    "Show_details": mystring("my_substring_with_spaces"),
    "Type_of_event": mystring("my_substring_with_spaces2"),
}

What I tried

I only managed to get the `my_substring_with_spaces`. But I do not understand how to proceed further.
Search: mystring\("([a-z]*?( )[a-z]*?)"\)
Mike Casan Ballester
  • 1,690
  • 19
  • 33

1 Answers1

2

You can use

(?<=mystring\("[^"]*)\s+(?=[^"]*"\))

Details

  • (?<=mystring\("[^"]*) - immediately to the left, there must be mystring(" and then 0 or more chars other than "
  • \s+ - one or more whitespaces (remove + if two consecutive spaces must be converted to two consecutive _s)
  • (?=[^"]*"\)) - immediately to the right, there must be 0 or more chars other than " and then ").

See the screenshot:

enter image description here

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563