Page 1 of 1

find and remove pattern

Posted: Sun Jan 18, 2015 2:40 pm
by vx53
Hello!
I am experiencing some difficulties.
Could You help me?
Is it possible to find a string of the form (html file):

<tr class="OutOfBlock"><td /><td>DD.MM.YYYY</td><td>HH:MM:SS</td><td>+HH:00</td><td>some text with ()_:,. etc.</td><td>some text with ()_:,. etc.</td><td></td><td>some text with ()_:,. etc.</td><td></td><td>some text with ()_:,. etc.</td><td>0,0000</td><td /></tr>

and remove it if in the end found "0,0000"?
*the date and time, timezone variable.
In advance i thank you for the assistance provided.
Best regards.

Re: find and remove pattern

Posted: Wed Jan 21, 2015 12:10 pm
by DigitalVolcano
This should find the block-

Code: Select all

<tr class="OutOfBlock"><td /><td>DD\.MM\.YYYY</td><td>HH:MM:SS</td><td>\+HH:00</td><td>.*?</td><td>.*?</td><td></td><td>.*?</td><td></td><td>.*?</td><td>0,0000</td><td /></tr>
note the escaped characters and the wildcards.

You can replace with nothing to remove the strings. Always backup first!

Re: find and remove pattern

Posted: Thu Jan 22, 2015 8:02 pm
by vx53
Hmmm, ... I have a html file containing some similar lines, here are some (internal code) of them:
<tr class="OutOfBlock"><td /><td>01.11.2014</td><td>17:15:43</td><td>+03:00</td><td>smsvsr_723</td><td>Location: asdfgh</td><td></td><td>sms o</td><td></td><td>1</td><td>3,3474</td><td /></tr>
<tr class="OutOfBlock"><td /><td>01.11.2014</td><td>17:16:05</td><td>+03:00</td><td></td><td>Location: zxcvbn</td><td></td><td>ussd</td><td>U</td><td>1</td><td>0,0000</td><td /></tr>
<tr class="OutOfBlock"><td /><td>27.11.2014</td><td>10:32:26</td><td>+03:00</td><td>smsvsr_1234</td><td>Location: qwerty</td><td></td><td>sms o</td><td></td><td>1</td><td>0,0000</td><td /></tr>
after applying the script patterns (<tr ... </tr>) containing 0,0000 must be removed.
For example, upon detection of template <tr ... 0,0000 ... </ tr> this line is removed.
* When I enter your expression, nothing happens (probably need to convert, for example, to search for <tr need to write \<tr etc.)
Is this possible?
Thank you.

Re: find and remove pattern

Posted: Mon Feb 02, 2015 11:18 am
by DigitalVolcano
It's probably because the expression literally looks for HH.MM.SS, etc. I didn't realize that they were placeholders for actual values in the file.

This may work, if it's not too nonspecific:

Code: Select all

<tr class="OutOfBlock"><td /><td>.*?</td><td>.*?</td><td>.*?</td><td>.*?</td><td>.*?</td><td></td><td>.*?</td><td></td><td>.*?</td><td>0,0000</td><td /></tr>

Re: find and remove pattern

Posted: Mon Feb 02, 2015 7:19 pm
by vx53
Unfortunately, beginning marker is set incorrectly:
instead remove only the second line, the script removes both

Code: Select all

<tr class="OutOfBlock"><td /><td>DD.MM.YYYY</td><td>HH:MM:SS</td><td>+HH:MM</td><td></td><td></td><td></td><td></td><td></td><td></td><td>40,0000</td><td /></tr>
<tr class="OutOfBlock"><td /><td>DD.MM.YYYY</td><td>HH:MM:SS</td><td>+HH:MM</td><td></td><td></td><td></td><td></td><td></td><td></td><td>0,0000</td><td /></tr>
Is there a solution?