This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes pattern matching doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "pattern matching doubt" Watch "pattern matching doubt" New topic
Author

pattern matching doubt

akila sekaran
Ranch Hand

Joined: Jun 12, 2012
Posts: 48
i used the following string to match files that have .cpp or c++ or cc extension. but it gives error. I think some problem is there is the syntax. But no idea what it would be.

Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1456
    
    5

akila sekaran wrote:but it gives error

Please, TellTheDetails. What is the error? (by 'error', do you mean compilation error? in that case, a single line of code won't help us to figure out the actual problem)

Also, during pattern matching, (at least I) follow the process of 'starting with small' - e.g. firstly, make the code working with '.' in the string, then make it working with .cpp, and then go for multiple extensions.

I hope this helps.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7024
    
  16

Akila, I really think you need to read the HowToAskQuestionsOnJavaRanch (←click) page.

Just providing a few lines of code and firing off vague questions like "I have a doubt about..." or "I think there's some problem, but..." gives the impression that you:
(a) Haven't bothered to read the tutorials (or the requisite material for your class).
(b) Haven't made an effort to at least try some solutions yourself.
(c) Want someone else to do your work for you.

Now all of the above may be false, but you need to learn to ask precise questions to avoid giving that impression.
My advice: After you've read our page, have a look at this one and this one. The first contains several excellent tips on how to formulate questions properly, particularly ones that involve programming code, and the second is a great general guide to asking question on sites like ours.

Remember: It's the policy of this site not to just "hand out answers".

Thanks.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Ashwin Soni
Greenhorn

Joined: Jun 22, 2012
Posts: 18

According to 1 line of code you have given it will give "illegal escape character" error at compile time. And this error occurs if you attempt to use backlash before a wrong character where it shouldn't be.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
You need to replace the single \ with \\ before the dot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: pattern matching doubt
 
Similar Threads
Confused for threading ?
How to create a JVM in native code and call a Java Method from a Java Class?
Eclipse for java & cpp/h files in openjdk
how to use c/cpp code in java??
Help with c++ and cmd.exe