Page 1 of 1

I need help to find the solution to find a ";"

Posted: Sat Apr 19, 2008 4:01 pm
by neo67
Hello,

I try several ours to find the semicolon in this:
One line (row):

Code: Select all

<DESCRIPTION_LONG>PVC-Steuerleitungen 2YSL(St)CYv-J Norm:  - Nennspannung: 0,6/1 kV Isolier-/Mantelwerkstoff: PVC, verstärkt Farbe: schwarz Flammwidrigkeit: nach VDE 0472 Teil 804 Prüfart B (=IEC 332-1) ; Verwendung: Die Leitung ist speziell für das EMV-gerechte Anschließen von Frequenzumrichtern entwickelt. Für feste Verlegung und gelegentliche Bewegung in Innenräumen und im Freien. auf Trommel. Basis 150&lt;p&gt;Kupfer (kg pro 100m): 23,5&lt;p&gt;Außen-& # 2 4 9; (mm): 14,5</DESCRIPTION_LONG>
In this are several semicolons like:

Code: Select all

&lt; gt; & # 2 4 9;
. They are okay, because they are html code or ASCII Code.
But I will find this Semicolon:

Code: Select all

(=IEC 332-1) ;
This are description of our articles. And someone did Semicolons in there. How can I find semicolons, which are not like:

Code: Select all

&lt; gt; & # 2 4 9;
.

I try this:

Code: Select all

<DESCRIPTION_LONG>[^&#...;][^&lt;][^&gt;].*;
But textpad find everytime, if the semicolon is there or not..... :(

can anybody help me? Because I have 25 Bil. lines....
Thanks a lot!

neo67

Posted: Sun Apr 20, 2008 4:56 pm
by ben_josephs
You misunderstand the character class notation [...]. A character class expression matches exactly one character. For example, your expression [^&#...;] matches any one character that is not &, #, . or ;, since it begins with a ^.

In TextPad you cannot find text that does not match an arbirary regular expression. Can you rephrase your requirement to indicate what you are looking for? - for example, semicolons preceded by a single character that isn't a letter or digt? This regular expression will match those:
[^a-z0-9];

Posted: Mon Apr 21, 2008 7:07 am
by neo67
ben_josephs wrote:You misunderstand the character class notation [...]. A character class expression matches exactly one character. For example, your expression [^&#...;] matches any one character that is not &, #, . or ;, since it begins with a ^.

In TextPad you cannot find text that does not match an arbirary regular expression. Can you rephrase your requirement to indicate what you are looking for? - for example, semicolons preceded by a single character that isn't a letter or digt? This regular expression will match those:
[^a-z0-9];
Thanks for your answer, I search the semilcolons ";" which are not in &amp; or &gt; and other html or ascii code. That means a ";" which stands alone and not in relationship with html code.

thanks!
neo67

Posted: Mon Apr 21, 2008 11:44 am
by ben_josephs
That describes the semicolons you are not looking for, not the ones you are looking for.

Does my suggestion not work? If so, what does it find that you are not looking for, and what does it not find that you are looking for?

Posted: Mon Apr 21, 2008 12:04 pm
by neo67
No, I describe, what I'm looking for:
That means a ";" which stands alone and not in relationship with html code.
The solution does not work:

Two Example:

Line 1 (line is correct, nothing found):

Code: Select all

<DESCRIPTION_LONG>PVC-Steuerleitungen 2YSL(St)CYv-J Norm: &lt;p&gt;Außen- & # 2 4 9; (mm): 14,5</DESCRIPTION_LONG>
Line 2 (line is not correct, nothing found):

Code: Select all

<DESCRIPTION_LONG>PVC-Steuerleitungen 2YSL(St)CYv-J Norm: ; &lt;p&gt;Außen- & # 2 4 9 ; (mm): 14,5</DESCRIPTION_LONG>
In Line 2 the semicolon here "Norm: ;" is wrong and have to delete.

Thanks
neo67

Posted: Mon Apr 21, 2008 12:50 pm
by ben_josephs
neo67 wrote:No, I describe, what I'm looking for:
That means a ";" which stands alone and not in relationship with html code.
It's the word "not" that is the problem.
neo67 wrote:Line 2 (line is not correct, nothing found):

Code: Select all

<DESCRIPTION_LONG>PVC-Steuerleitungen 2YSL(St)CYv-J Norm: ; &lt;p&gt;Außen- & # 2 4 9 ; (mm): 14,5</DESCRIPTION_LONG>
In Line 2 the semicolon here "Norm: ;" is wrong and have to delete.
I don't understand. My suggested regular expression does find the semicolon in
Norm: ;
because it's preceded by a space, which isn't a letter or a digit.

Posted: Mon Apr 21, 2008 2:08 pm
by neo67
Yes, you are right. I think, my cursor was an the wrong place. Sorry.

But, how can I find the simcolon behind "Steuerleitungen;"

Code: Select all

<DESCRIPTION_LONG>PVC-Steuerleitungen; 2YSL(St)CYv-J Norm: &lt;p&gt;Außen- & # 2 4 9 ; (mm): 14,5</DESCRIPTION_LONG>
My main problem is, that semicolons behind as &lt; or &gt; are correct, because the are part of a html code. But semicolons, which stands anywehre in this row are not correct and interrupt my import.

And this I have to find in 25 Billions rows. :(

Posted: Tue Apr 22, 2008 8:43 am
by ben_josephs
As I understand it, you want to find those semicolons that are not preceded by text that matches either &[a-z]+ or &#[0-9]+. There's no easy way that I am aware of to do that in TextPad.

What you need is a means to specify, positively or negatively, the context around the semicolons. Look-ahead and look-behind constructs provide these means, but they are not available with TextPad's aged regular expression recogniser. Look-ahead, which looks at the context following the text you want to match, is available in WildEdit; but what you need is look-behind, which looks at the context preceding the text you want to match, and that is not available in WildEdit. With positive look-behind you can specify what the text you are interested in must be preceded by. With negative look-behind you can specify what it must not be preceded by. So it is negative look-behind you need.

However, most languages that provide look-behind impose the restriction that all matches of the look-behind expression must be of the same length. So you have to specify separately look-behind expressions of different lengths, say:
&[a-z]{2}
&[a-z]{3}
&[a-z]{4}
&#[0-9]
&#[0-9]{2}
&#[0-9]{3}

For example, in Perl, this or a similar regular expression matches just the semicolons you want to remove:
(?<!&[a-z]{2})(?<!&[a-z]{3})(?<!&[a-z]{4})(?<!&#[0-9])(?<!&#[0-9]{2})(?<!&#[0-9]{3});

Posted: Tue Apr 22, 2008 8:59 am
by neo67
I try it. But....

[url=httpx://www.bilder-hochladen.net/files/2smt-t-png.html][img]httpx://www.bilder-hochladen.net/files/thumbs/2smt-t.png[/img][/url]
[/img]

Link edited by moderator to eliminate ads.

Posted: Tue Apr 22, 2008 9:45 am
by ben_josephs
ben_josephs wrote:There's no easy way that I am aware of to do that in TextPad...

Look-ahead and look-behind constructs provide these means, but they are not available with TextPad's aged regular expression recogniser.
Please don't provide links to pages with pop-up adverts.

Posted: Tue Apr 22, 2008 9:47 am
by neo67
???
this is an image and no popup....

Posted: Tue Apr 22, 2008 9:56 am
by ben_josephs
You are mistaken:
<script src="http://layer-ads.de/la-5558-subid:BHup.js" type="text/javascript"></script>

Posted: Tue Apr 22, 2008 8:00 pm
by HerNameWasTextPad
Can we be reasonably certain that all ILLEGITIMATE semicolons in your code ARE preceded by spaces? In other words, could there be any that are NOT preceded by spaces?

If some of the illegitimate semicolons are preceded by characters other than spaces, then can we be reasonably certain as to what those non-space characters are? In other words, is there a definite regularity to the characters that precede the illegitimate semi-colons?

(Can we be reasonably certain that all LEGITIMATE semicolons in your code are NOT preceded by spaces? In other words, could there be any that ARE preceded by spaces?)

These are important questions, because coming up with accurate regular expressions depends ENTIRELY upon what the implementer of those expressions is ABLE TO KNOW about the code that is to be searched.

If the situation is such that there is no way to know EXACTLY what lurks in the code that is to be searched, then we are all . . . "up the creek without a paddle."

If we are to do this accurately (why would we want to do it any other way?), we need to identify the presence of some kind of regularity--about the illegitimate semicolons--upon which we can depend 100%.

Is there any other character or pattern of characters (such as parentheses or an acronym) that ALWAYS precedes (or succeeds), in some nearby and consistent way, an illegitimate semi-colon? If this is not able to be known, by the code, . . . my heart goes out to you. 25 billion lines makes me shudder.

The final thing to mention is that breaking up a search into a number of simpler searches can often increase the power of regular expressions.

So, try to analyze the situation with as much detail as you can.

Sorry if some of this sounds obvious, especially to those who are very experienced with REs; however, different perspectives are often useful and FOCUSING on what is of the utmost importance can often be beneficial.