haw to remove all lines contains specified caracters ?
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 2
- Joined: Sat Apr 19, 2014 9:02 am
haw to remove all lines contains specified caracters ?
Heloo
I need help with editing xml file with many producs ( >1000)
I want to remove all lines with contain specified caracters, for example my code is:
<media><images>http://www.chinabuye.com/media/catalog/ ... es></media>
I need to remove all lines contains "<images>http://www.chinabuye.com/media/catalog/product/f/i/"
or all lines with images like that: <images>http://www.chinabuye.com/media/catalog/ ... pg</images>
I need to keep only this type of images : <images>http://www.chinabuye.com/media/catalog/ ... pg</images> what contains a number after: <images>http://www.chinabuye.com/media/catalog/product/
what method exists for this ?
thanks
I need help with editing xml file with many producs ( >1000)
I want to remove all lines with contain specified caracters, for example my code is:
<media><images>http://www.chinabuye.com/media/catalog/ ... es></media>
I need to remove all lines contains "<images>http://www.chinabuye.com/media/catalog/product/f/i/"
or all lines with images like that: <images>http://www.chinabuye.com/media/catalog/ ... pg</images>
I need to keep only this type of images : <images>http://www.chinabuye.com/media/catalog/ ... pg</images> what contains a number after: <images>http://www.chinabuye.com/media/catalog/product/

thanks
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: haw to remove all lines contains specified caracters ?
Hi,
Removing entire lines is a bit extreme, you could accidentally remove useful code found on the same line. Are you sure it's the entire lines you want to remove and not just the respective elements?
You can use the Find/Replace dialog (or Find/Replace in Files for multiple files) from Oxygen with a regular expression like the following.
- For removing entire lines (not recommended):
If you want to also match/remove the line breaks (the empty lines), add a \n at the end of the expression (after the $).
- For removing only the specific images elements (recommended):
To explain the expression:
- ^ is the line start
- .*? is a sequence of any number of characters (non-greedy)
- \Q and \E - start/end literal quote (characters between \Q and the next \E are taken literally and are not interpreted as regular expressions)
- $ is the line end.
Make sure the Regular expression option is enabled and use the Find/Replace and/or the Find All/Replace All buttons.
Regards,
Adrian
Removing entire lines is a bit extreme, you could accidentally remove useful code found on the same line. Are you sure it's the entire lines you want to remove and not just the respective elements?
You can use the Find/Replace dialog (or Find/Replace in Files for multiple files) from Oxygen with a regular expression like the following.
- For removing entire lines (not recommended):
Code: Select all
^.*?<images>\Qhttp://www.chinabuye.com/media/catalog/product/f/i/\E.*?$
- For removing only the specific images elements (recommended):
Code: Select all
<images>\Qhttp://www.chinabuye.com/media/catalog/product/f/i/\E.*?</images>
- ^ is the line start
- .*? is a sequence of any number of characters (non-greedy)
- \Q and \E - start/end literal quote (characters between \Q and the next \E are taken literally and are not interpreted as regular expressions)
- $ is the line end.
Make sure the Regular expression option is enabled and use the Find/Replace and/or the Find All/Replace All buttons.
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
Return to “General XML Questions”
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