RegEx blocks

Hi @ all.

I need assistance "m.find()" blocked. Here is the code:

Pattern p = Pattern.compile("(([0-9]+\\.?\\,?[0-9]*)+\\s?[X\\*\\/]{1}\\s?)*");

Matcher m = p.matcher("739967,739969,739966,739968");

System.out.println(m.find());

I use sdk 1.5_0_8

Thanks

DG1LEO

[359 byte] By [dg1leoa] at [2007-11-27 11:23:10]
# 1

> Hi @ all.

> I need assistance "m.find()" blocked. Here is the

> code:

>

> ...

Do you care to elaborate on what it exactly is you're trying to do?

prometheuzza at 2007-7-29 14:59:06 > top of Java-index,Java Essentials,Java Programming...
# 2

I do not think that am important and my english is not well enough to describe that exactly but

1. Thats not my complete RegEx, the complete reads:

"(([0-9]+\\.?\\,?[0-9]*)+\\s?[X\\*\\/]{1}\\s?)*([0-9]+\\.?\\,?[0-9]*)+[^A-Z]?(METER|MTR|LFM|MM|QM|CM|ML|M$|M[^A-Z]|LITER|LTR|L$|L[^A-Z]|KILO|KG|GRAD|G$|G[^A-Z]|ZOLL|VOLT|V[^A-Z]|V$|WATT|KW|W$|W[^A-Z]|C|STUECK|STCK|STK|ST$|ST[^A-Z])+"

2. I try to find statements of size like:

"3,5X9,6X4,5 METER" or "3,5*2,8 VOLT" or "88 / 34 LITER" and so on...

3. It functions with approximately 200.000 data records, but with the one it remains hanging.

DG1LEO

dg1leoa at 2007-7-29 14:59:06 > top of Java-index,Java Essentials,Java Programming...
# 3

Which one is that?

CeciNEstPasUnProgrammeura at 2007-7-29 14:59:06 > top of Java-index,Java Essentials,Java Programming...
# 4

Pattern p = Pattern.compile("(([0-9]+\\.?\\,?[0-9]*)+\\s?[X\\*\\/]{1}\\s?)*([0-9]+\\.?\\,?[0-9]*)+[^A-Z]?(METER|MTR|LFM|MM|QM|CM|ML|M$|M[^A-Z]|LITER|LTR|L$|L[^A-Z]|KILO|KG|GRAD|G$|G[^A-Z]|ZOLL|VOLT|V[^A-Z]|V$|WATT|KW|W$|W[^A-Z]|C|STUECK|STCK|STK|ST$|ST[^A-Z])+");

Matcher m = p.matcher("LAKRITZ MUENZEN NORD * BITTE MIT 739967,739969,739966,739968 BEST.");

System.out.println(m.find());

m.find() blocks.

dg1leoa at 2007-7-29 14:59:06 > top of Java-index,Java Essentials,Java Programming...
# 5

> I do not think that am important and my english is

> not well enough to describe that exactly but

I think it is important.

> 1. Thats not my complete RegEx, the complete reads:

> "(([0-9]+\\.?\\,?[0-9]*)+\\s?[X\\*\\/]{1}\\s?)*(

> [0-9]+\\.?\\,?[0-9]*)+[^A-Z]?(METER|MTR|LFM|MM|QM|CM|M

> L|M$|M[^A-Z]|LITER|LTR|L$|L[^A-Z]|KILO|KG|GRAD|G$|G[^A

> -Z]|ZOLL|VOLT|V[^A-Z]|V$|WATT|KW|W$|W[^A-Z]|C|STUECK|

> STCK|STK|ST$|ST[^A-Z])+"

> 2. I try to find statements of size like:

> "3,5X9,6X4,5 METER" or "3,5*2,8 VOLT" or "88 / 34

> LITER" and so on...

> 3. It functions with approximately 200.000 data

> records, but with the one it remains hanging.

>

> DG1LEO

And a few remarks about your regex:

[X\\*\\/]{1}

The '*' and '/' are no meta characters inside a character class and thus they need not be escaped. The {1} is redundant. A character class always matches one character.

If you want to match either '*', '/' or 'X', this is sufficient: [X*/].

([0-9]+\\.?\\,?[0-9]*)

0., will be matched by this part of your regex which I don't think is what you have in mind.

prometheuzza at 2007-7-29 14:59:06 > top of Java-index,Java Essentials,Java Programming...
# 6

Hello prometheuzz -Thanks for your answer!

I am RegEx newbie...

You have a better RegEx for each kind of numbers as for example

"1" "0,1" "0.1" "1.000,00"?

I scanned the data base ".," do not occur.

DG1LEO

dg1leoa at 2007-7-29 14:59:06 > top of Java-index,Java Essentials,Java Programming...
# 7

> Hello prometheuzz -Thanks for your answer!

> I am RegEx newbie...

> You have a better RegEx for each kind of numbers as

> for example

> "1" "0,1" "0.1" "1.000,00"?

> I scanned the data base ".," do not occur.

>

> DG1LEO

Well, I'd say something like this:"\\d+([.]\\d{3})*([.,]\\d+)?"

Note that \\d is the same as [0-9].

But it's still unclear to me what you are trying to match in the String "LAKRITZ MUENZEN NORD * BITTE MIT 739967,739969,739966,739968 BEST."

prometheuzza at 2007-7-29 14:59:07 > top of Java-index,Java Essentials,Java Programming...