Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Thanks grawity, it helped me broaden my search to herehere to cover multiple search and replace in one regex.

Trying the following works:

Find: </ITEM_.*(>)|<ITEM_(.*)(>)
Replace: (?1</ITEM>)(?2<ITEM>\n<ID>\2</ID>)
RegEx

The | separates 2 strings looked for and the ?1 and ?2 are their respective replacements.

But I have to look for the closing </ITEM tag first, not the <ITEM tag as you would logically figure. So I have a solution, but can anyone answer the question as to why the above works but the following, looking for <ITEM tag first, fails when we're just reversing the order in which we look?

Find: <ITEM_(.*)(>)|</ITEM_.*(>)
Replace: (?1<ITEM>\n<ID>\1</ID>)(?2</ITEM>
RegEx

Not essential, but enquiring minds might like to know. Thanks.

Thanks grawity, it helped me broaden my search to here to cover multiple search and replace in one regex.

Trying the following works:

Find: </ITEM_.*(>)|<ITEM_(.*)(>)
Replace: (?1</ITEM>)(?2<ITEM>\n<ID>\2</ID>)
RegEx

The | separates 2 strings looked for and the ?1 and ?2 are their respective replacements.

But I have to look for the closing </ITEM tag first, not the <ITEM tag as you would logically figure. So I have a solution, but can anyone answer the question as to why the above works but the following, looking for <ITEM tag first, fails when we're just reversing the order in which we look?

Find: <ITEM_(.*)(>)|</ITEM_.*(>)
Replace: (?1<ITEM>\n<ID>\1</ID>)(?2</ITEM>
RegEx

Not essential, but enquiring minds might like to know. Thanks.

Thanks grawity, it helped me broaden my search to here to cover multiple search and replace in one regex.

Trying the following works:

Find: </ITEM_.*(>)|<ITEM_(.*)(>)
Replace: (?1</ITEM>)(?2<ITEM>\n<ID>\2</ID>)
RegEx

The | separates 2 strings looked for and the ?1 and ?2 are their respective replacements.

But I have to look for the closing </ITEM tag first, not the <ITEM tag as you would logically figure. So I have a solution, but can anyone answer the question as to why the above works but the following, looking for <ITEM tag first, fails when we're just reversing the order in which we look?

Find: <ITEM_(.*)(>)|</ITEM_.*(>)
Replace: (?1<ITEM>\n<ID>\1</ID>)(?2</ITEM>
RegEx

Not essential, but enquiring minds might like to know. Thanks.

deleted 2 characters in body
Source Link
Catch21
  • 51
  • 1
  • 7

Thanks grawity, it helped me broaden my search to here to cover multiple search and replace in one regex.

Trying the following works:

Find: </ITEM_.*(>)|<ITEM_(.*)(>)
Replace: (?1</ITEM>)(?2<ITEM>\n<ID>\2\<2<ITEM>\n<ID>\2</ID>)
RegEx

The | separates 2 strings looked for and the ?1 and ?2 are their respective replacements.

But I have to look for the closing </ITEM tag first, not the <ITEM tag as you would logically figure. So I have a solution, but can anyone answer the question as to why the above works but the following, looking for <ITEM tag first, fails when we're just reversing the order in which we look?

Find: <ITEM_(.*)(>)|</ITEM_.*(>)
Replace: (?1<ITEM>\n<ID>\1\<1<ITEM>\n<ID>\1</ID>)(?2</ITEM>
RegEx

Not essential, but enquiring minds might like to know. Thanks.

Thanks grawity, it helped me broaden my search to here to cover multiple search and replace in one regex.

Trying the following works:

Find: </ITEM_.*(>)|<ITEM_(.*)(>)
Replace: (?1</ITEM>)(?2<ITEM>\n<ID>\2\</ID>)
RegEx

The | separates 2 strings looked for and the ?1 and ?2 are their respective replacements.

But I have to look for the closing </ITEM tag first, not the <ITEM tag as you would logically figure. So I have a solution, but can anyone answer the question as to why the above works but the following, looking for <ITEM tag first, fails when we're just reversing the order in which we look?

Find: <ITEM_(.*)(>)|</ITEM_.*(>)
Replace: (?1<ITEM>\n<ID>\1\</ID>)(?2</ITEM>
RegEx

Not essential, but enquiring minds might like to know. Thanks.

Thanks grawity, it helped me broaden my search to here to cover multiple search and replace in one regex.

Trying the following works:

Find: </ITEM_.*(>)|<ITEM_(.*)(>)
Replace: (?1</ITEM>)(?2<ITEM>\n<ID>\2</ID>)
RegEx

The | separates 2 strings looked for and the ?1 and ?2 are their respective replacements.

But I have to look for the closing </ITEM tag first, not the <ITEM tag as you would logically figure. So I have a solution, but can anyone answer the question as to why the above works but the following, looking for <ITEM tag first, fails when we're just reversing the order in which we look?

Find: <ITEM_(.*)(>)|</ITEM_.*(>)
Replace: (?1<ITEM>\n<ID>\1</ID>)(?2</ITEM>
RegEx

Not essential, but enquiring minds might like to know. Thanks.

added 93 characters in body
Source Link
Catch21
  • 51
  • 1
  • 7

Thanks grawity, it helped me broaden my search to here to cover multiple search and replace in one regex.

Trying the following works:

Find: </ITEM_.*(>)|<ITEM_(.*)(>)
Replace: (?1</ITEM>)(?2<ITEM>\n<ID>\2\</ID>)
RegEx

The | separates 2 strings looked for and the ?1 and ?2 are their respective replacements.

But I have to look for the closing </ITEM tag first, not the <ITEM tag as you would logically figure. So I have a solution, but can anyone answer the question as to why the above works but the following, looking for <ITEM tag first, fails when we're just reversing the order in which we look?

Find: <ITEM_(.*)(>)|</ITEM_.*(>)
Replace: (?1<ITEM>\n<ID>\1\</ID>)(?2</ITEM>
RegEx

Not essential, but enquiring minds might like to know. Thanks.

Thanks grawity, it helped me broaden my search to here.

Trying the following works:

Find: </ITEM_.*(>)|<ITEM_(.*)(>)
Replace: (?1</ITEM>)(?2<ITEM>\n<ID>\2\</ID>)
RegEx

But I have to look for the closing </ITEM tag first, not the <ITEM tag as you would logically figure. So I have a solution, but can anyone answer the question as to why the above works but the following, looking for <ITEM tag first, fails when we're just reversing the order in which we look?

Find: <ITEM_(.*)(>)|</ITEM_.*(>)
Replace: (?1<ITEM>\n<ID>\1\</ID>)(?2</ITEM>
RegEx

Not essential, but enquiring minds might like to know. Thanks.

Thanks grawity, it helped me broaden my search to here to cover multiple search and replace in one regex.

Trying the following works:

Find: </ITEM_.*(>)|<ITEM_(.*)(>)
Replace: (?1</ITEM>)(?2<ITEM>\n<ID>\2\</ID>)
RegEx

The | separates 2 strings looked for and the ?1 and ?2 are their respective replacements.

But I have to look for the closing </ITEM tag first, not the <ITEM tag as you would logically figure. So I have a solution, but can anyone answer the question as to why the above works but the following, looking for <ITEM tag first, fails when we're just reversing the order in which we look?

Find: <ITEM_(.*)(>)|</ITEM_.*(>)
Replace: (?1<ITEM>\n<ID>\1\</ID>)(?2</ITEM>
RegEx

Not essential, but enquiring minds might like to know. Thanks.

Source Link
Catch21
  • 51
  • 1
  • 7
Loading