Page 1 of 1

haw to remove all lines contains specified caracters ?

Posted: Sat Apr 19, 2014 9:17 am
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

Re: haw to remove all lines contains specified caracters ?

Posted: Tue Apr 22, 2014 11:37 am
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

Re: haw to remove all lines contains specified caracters ?

Posted: Tue Apr 22, 2014 2:32 pm
by cojocarua
thank you verry much :D :D :D