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.

5
  • 1
    try id="([0-9]+)-([0-9]+)" Commented Jun 10, 2013 at 23:43
  • Oh hell. I don't know where my mind was to forget the +. Thank you! Commented Jun 10, 2013 at 23:45
  • happens to the best of us :) Commented Jun 10, 2013 at 23:46
  • stackoverflow.com/questions/1732348/… Commented Jun 10, 2013 at 23:46
  • @JimGarrison I don't think it's related... Commented Jun 10, 2013 at 23:57

2 Answers 2

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+)"

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

1 Comment

Oh this is a very complex one. I see you also prevented tags like "id = "108-109"". That doesn't happen certainly, but thanks.
2

try the following

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

Comments

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.