Is there a way to replace everything but keep data that was found by wild card
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 3
- Joined: Fri Oct 29, 2021 11:31 pm
Is there a way to replace everything but keep data that was found by wild card
find this set of data
</NEW>
</Id>
<Bubble>
<Ctr>.*?</Ctr>
</Bubble>
</OCtPt>
Replace this but where the wildcard data is I need it to keep the data that is in the document.
</NEW>
</LLG>
</Id>
<Bubble>
<Ctr>.*?</Ctr>
</Bubble>
</OCtPt>
Is there any way to do this?
</NEW>
</Id>
<Bubble>
<Ctr>.*?</Ctr>
</Bubble>
</OCtPt>
Replace this but where the wildcard data is I need it to keep the data that is in the document.
</NEW>
</LLG>
</Id>
<Bubble>
<Ctr>.*?</Ctr>
</Bubble>
</OCtPt>
Is there any way to do this?
-
- Posts: 93
- Joined: Fri Mar 08, 2013 8:58 am
Re: Is there a way to replace everything but keep data that was found by wild card
Yes, use parentheses in the find field and back references in the replace field.
Where you have .*? use (.*?) in your first block of code and \1 in your second. (Note that if you're doing this in XPath, you need to use $1, but not in Oxygen's search/replace dialogue.)
Background reading:
https://www.oxygenxml.com/doc/versions/ ... ialog.html
https://www.regular-expressions.info/
Where you have .*? use (.*?) in your first block of code and \1 in your second. (Note that if you're doing this in XPath, you need to use $1, but not in Oxygen's search/replace dialogue.)
Background reading:
https://www.oxygenxml.com/doc/versions/ ... ialog.html
https://www.regular-expressions.info/
-
- Posts: 3
- Joined: Fri Oct 29, 2021 11:31 pm
Re: Is there a way to replace everything but keep data that was found by wild card
I need to explain it better.
In my document I found 21 data rows. Meaning I have hundreds of xml tag (data rows)
<start>multiple tags and data my regex search found the 21 I wanted</start>
I either want to extract the 21 data rows or delete all the other hundreds of data rows.
for this one since there was only 21 I just manually copied and pasted them in a new xml but in future there may be hundreds so I would like to have something that would make the process more automated.
In my document I found 21 data rows. Meaning I have hundreds of xml tag (data rows)
<start>multiple tags and data my regex search found the 21 I wanted</start>
I either want to extract the 21 data rows or delete all the other hundreds of data rows.
for this one since there was only 21 I just manually copied and pasted them in a new xml but in future there may be hundreds so I would like to have something that would make the process more automated.
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Is there a way to replace everything but keep data that was found by wild card
Hi,
If we are talking about XML, you could write an XPath expression that matches the rows that you want and use the XPath/XQuery Builder (XQuery part) to extract the data in a new document.
See my post from this topic on how the XPath/XQuery Builder can be used to extract data:
post64012.html#p64012
Regards,
Adrian
Find/Replace isn't meant to be used to extract data, it's just a text search/replace tool. You could flip the logic in the regex and use it to delete the rows that you don't need, but that's about it.I either want to extract the 21 data rows or delete all the other hundreds of data rows.
If we are talking about XML, you could write an XPath expression that matches the rows that you want and use the XPath/XQuery Builder (XQuery part) to extract the data in a new document.
See my post from this topic on how the XPath/XQuery Builder can be used to extract data:
post64012.html#p64012
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service