473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Regular Expression Issue

karlectomy
Hi there,

I am parsing some text files using a buffered reader. I use regular expressions to match different lines to their appropriate cases. I can parse one file fine but when I run the parse on multiple files, I get

Exception in thread "main" java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 3
view)

The thing is, I never get it in the same place twice. It will occur in the middle of words and never in the same word twice. I don't know if anyone might have an inkling of an idea on this one...

here are the patterns I'm using:

Expand|Select|Wrap|Line Numbers
  1. Pattern origin = Pattern.compile("Date of origin: .*");
  2. Pattern review = Pattern.compile("Last review date: .*");
  3. Pattern condition = Pattern.compile("Clinical Condition: .+");
  4. Pattern variant = Pattern.compile("Variant \\d+: .+");
  5. Pattern blank = Pattern.compile("\\s*");
  6. Pattern Heading4 = Pattern.compile("Radiologic Procedure Rating .*");
  7. Pattern Heading3 = Pattern.compile("Rating Comments.*");
  8. Pattern Footer4 = Pattern.compile("Rating Scale: .+");
  9. Pattern Footer3 = Pattern.compile("Appropriateness Criteria Scale.*");
  10. Pattern References = Pattern.compile("References.*");
  11. Pattern PageHeaderStart = Pattern.compile("An ACR Committee on Appropriateness Criteria and its expert panels have developed criteria for determining appropriate imaging examinations for diagnosis and treatment of specified medical.*");
  12. Pattern ReferenceStart = Pattern.compile("\\d+\\Q.\\E .+");
  13.  
Wishes,

Karl
Jan 3 '08 #1
6 2609
BigDaddyLH
1,216 Expert 1GB
I can parse one file fine but when I run the parse on multiple files, I get

Exception in thread "main" java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 3
view)
This doesn't make sense. Your code should be parsing each file separately, so if it can parse file1 or file2, it should be able to parse them in succession. The error must be somewhere in the logic where you change from one file to multiple files.
Jan 3 '08 #2
This doesn't make sense. Your code should be parsing each file separately, so if it can parse file1 or file2, it should be able to parse them in succession. The error must be somewhere in the logic where you change from one file to multiple files.
That's what I said... But there is not logic difference. I just call the same function in a for loop over an array of files from the parent directory...

All of the correct files are in the _files array which I iterate over. and I can run the parse on each file individually.

It opens several files fine but it will randomly? throw the regex.PatternSyntaxException: Unmatched closing ')' exception and it only works on the first 7 files... but I think that is an unrelated issue.

Expand|Select|Wrap|Line Numbers
  1.  
  2. for(File x: _files){
  3.     try{
  4.         AcrParser acr = new AcrParser(x.getCanonicalPath());
  5.         acr.parseText();
  6.     }catch(IOException e){
  7.         e.printStackTrace();
  8.     }
  9.  
  10. }
  11.  
And my Original call to the function:
Expand|Select|Wrap|Line Numbers
  1. AcrParser acr = new AcrParser("somefile.txt");
  2. acr.parseText();
  3.  
Jan 3 '08 #3
BigDaddyLH
1,216 Expert 1GB
I hope AcsParser doesn't have any static fields?

Beyond that, all I can suggest is to write a SSCCE: http://mindprod.com/jgloss/sscce.html
Jan 3 '08 #4
I hope AcsParser doesn't have any static fields?

Beyond that, all I can suggest is to write a SSCCE: http://mindprod.com/jgloss/sscce.html
THanks for your time,

I hope its not a simple "hoser at the keyboard error" as my highschool programming teacher used to say...

Yeah I built it from single file case up to multiple files... I am really frustrated because it seems the exceptions are being thrown at random and that doesn't help with debugging. My only idea is that maybe when comparing a string with a ( or ) in it, the regular expression engine farks up... I am going to try to replace parentheses with something... i don't know what yet.... BAHNAHBAHABAH
Jan 3 '08 #5
JosAH
11,448 Expert 8TB
@OP: you only showed us those compiled patterns. How do you use them to match
and optionally replace parts of the lines you just read from your files?

kind regards,

Jos
Jan 3 '08 #6
I found my problem... THere is a line in one of the files that I am parsing which consists of

view)

I am using the string matches function and not the regex engine to compare this line and it is getting all funky dunky on my badunky dunky...

My regular expressions were not the problem but thanks for the help.

May all your days be Exception free :)

Karl
Jan 3 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Lisa Bogart | last post by:
I am trying to take a string and parse it out into multiple strings based on a pattern but am stuck and am hoping someone can give me a clue. My pattern looks like so: sMatch =...
3
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
9
by: Pete Davis | last post by:
I'm using regular expressions to extract some data and some links from some web pages. I download the page and then I want to get a list of certain links. For building regular expressions, I use...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
6
by: deepak_kamath_n | last post by:
Hello, I am relatively new to the world of regex and require some help in forming a regular expression to achieve the following: I have an input stream similar to: Slot: slot1 Description:...
2
by: Prakash | last post by:
Dear Friends, In my web application i have two textboxes to collect "ORIGIN" and "DESTINATION" stations. These stations are represented as three letter code.. We have an option like to provide...
8
by: sri_san | last post by:
Hello, I am trying to write a regular expresssion which validates against the URL and the textfield has 'http://' prefilled. I either want a valid URL or just leave the 'http://' as it is. I...
12
by: =?Utf-8?B?SlA=?= | last post by:
I am a newbie to regular expressions and want to extract a number from the end of a string. The string would have these formats: image/4567 image/45678 image/456789 I would also want to...
18
by: Lit | last post by:
Hi, I am looking for a Regular expression for a password for my RegExp ValidationControl Requirements are, At least 8 characters long. At least one digit At least one upper case character
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.