haw to remove all lines contains specified caracters ?

Questions about XML that are not covered by the other forums should go here.
cojocarua
Posts: 2
Joined: Sat Apr 19, 2014 9:02 am

haw to remove all lines contains specified caracters ?

Post by cojocarua »

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
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: haw to remove all lines contains specified caracters ?

Post by adrian »

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):

Code: Select all

^.*?<images>\Qhttp://www.chinabuye.com/media/catalog/product/f/i/\E.*?$
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):

Code: Select all

<images>\Qhttp://www.chinabuye.com/media/catalog/product/f/i/\E.*?</images>
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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
cojocarua
Posts: 2
Joined: Sat Apr 19, 2014 9:02 am

Re: haw to remove all lines contains specified caracters ?

Post by cojocarua »

thank you verry much :D :D :D
Post Reply