0

So, I'm looking for a way to replace the entire instance of a <data> tag where the name contains '.Value'. I've whipped up a Regex for this (below), but it appears that VS2013 doesn't support multiline find/replace. I'm looking for a solution that doesn't require third party downloads (as this is for work).

Regex (works on http://www.regexr.com/):

  <data name=".*.Value" xml:space="preserve">\n    <value>.*</value>\n  </data>

Good (keep):

  <data name="ListItemResource12.Text" xml:space="preserve">
    <value>Test Value</value>
  </data>

Bad (replace):

  <data name="ListItemResource12.Value" xml:space="preserve">
    <value>123</value>
  </data>

If anyone has and ideas or tips toward multiline find/replace, they'd be appreciated.

Jmnstr
  • 80
  • 13

2 Answers2

1

Visual Studio does support multi-line regex search.

Your file probably uses \r\n; make sure your regex matches that.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

Don't use regex for this kind of thing, use an XML parser to change the values.

I'm a little rusty on my VS / C#, but using something like an XMLParser:

XMLParser(file.xml).findChildren("data").findChildren("value").setValue(123);
Community
  • 1
  • 1
BrDaHa
  • 5,138
  • 5
  • 32
  • 47
  • 1
    The OP's trying to perform a replacement *in the IDE itself*. – Lucas Trzesniewski May 05 '15 at 18:28
  • I don't know what kind of data the OP is working on, but if there are many files, and they're human-edited, then an XML parser would be the way to go instead of trying to handle every whitespace differentiation. A small program would be trivial to do so. – BrDaHa May 05 '15 at 18:37