regex question

hi, with this code (thanks to sabre150) i can find the three first words:

Pattern pattern = Pattern.compile("^(\\w+)\\s+(\\w+)\\s+(\\w+)");

Matcher matcher = pattern.matcher(partDesc);

here, regex has defined what a word is, i would like to set up the definitions for what a word is myself so i started off with something easy:

("^((a-zA-Z+)((\\.a-zA-z)|\\s)) instead of ("^(\\w+)\\s

with this one i'd like it to count capital and lower case a-z followed by a plank space or period+word+blank space as a word. this would include any normal word plus abbreviations such as "e.g".

it does compilate (word?) it alright... however when i run it, the output for this is:

java.io.IOException: Bad file descriptor

at java.io.FileInputStream.readBytes(Native Method)

at java.io.FileInputStream.read(FileInputStream.java:194)

at java.io.DataInputStream.read(DataInputStream.java:134)

at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(StreamDecoder.java:411)

at sun.nio.cs.StreamDecoder$CharsetSD.implRead(StreamDecoder.java:453)

at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:183)

at java.io.InputStreamReader.read(InputStreamReader.java:167)

at java.io.BufferedReader.fill(BufferedReader.java:136)

at java.io.BufferedReader.readLine(BufferedReader.java:299)

at java.io.BufferedReader.readLine(BufferedReader.java:362)

at Testar2.main(Testar2.java:23)

Does anyone understand why this won't work? i thought maybe it's my way of describing a period/full stop as \\.

...?

thank you in advance!

[1622 byte] By [SandraPandraa] at [2007-11-27 5:47:46]
# 1
puff
SandraPandraa at 2007-7-12 15:32:37 > top of Java-index,Java Essentials,Java Programming...
# 2

> ("^((a-zA-Z+)((\\.a-zA-z)|\\s)) instead of

> d of ("^(\\w+)\\s

>

> with this one i'd like it to count capital and lower

> case a-z followed by a plank space or

> period+word+blank space as a word. this would include

> any normal word plus abbreviations such as "e.g".

I think you want (a-zA-Z+) to be [a-zA-Z]+

There's a big difference. Please read the documentation for the pattern class, or take a look at www.regular-expressions.info

Kaj

Ps. The same applies to the rest of your regexp.

kajbja at 2007-7-12 15:32:37 > top of Java-index,Java Essentials,Java Programming...
# 3
that did make a large difference, how come the first one worked when it doesn't this time?
SandraPandraa at 2007-7-12 15:32:37 > top of Java-index,Java Essentials,Java Programming...
# 4
> how come the first> one worked when it doesn't this time?Read the tutorial.
sabre150a at 2007-7-12 15:32:37 > top of Java-index,Java Essentials,Java Programming...