0

I need to change the following text

<item id="108-109" name="flowers"/>

To this

<item fromid="108" toid="109" name="flowers"/>

On a file with multiple ocurrences of this 'id="num-num"' pattern. Name and the tag itselt doesn't matter. I've tried lots of different combinations of regex patterns and I can't find one which even finds something. This:

id="([0-9])-([0-9])"

Which in my mind should work is not working.

I'm using Notepad++ regex finder and testing with RegexPal, but after a lot of tries I'm out of ideas.

ranieri
  • 2,030
  • 2
  • 21
  • 39

2 Answers2

2

You can do this:

search: id\s*=\s*["'](\d+)-(\d+)["']
replace: fromid="$1" toid="$2"

since your comment, you can simply use:

search: id="(\d+)-(\d+)"

Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125
  • Oh this is a very complex one. I see you also prevented tags like "id = "108-109"". That doesn't happen certainly, but thanks. – ranieri Jun 10 '13 at 23:49
2

try the following

id="(\d+)-(\d+)"
Keith Nicholas
  • 43,549
  • 15
  • 93
  • 156