aspose file tools*
The moose likes Beginning Java and the fly likes solved: (finding) matching regex pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "solved: (finding) matching regex pattern" Watch "solved: (finding) matching regex pattern" New topic
Author

solved: (finding) matching regex pattern

Igor Mechnikov
Ranch Hand

Joined: Feb 13, 2011
Posts: 100

Howdy,

I am running an Interpreted Java script and trying to match a line of input to regex "td title".
Please tell me where I err.
Edit: I figured that .matches requires exact match.
I need a method that determines whether input contains a match for the regex.



Edit 2. This works:


String knock = "\u042F \u0418\u0433\u043e\u0440\u044c";
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Thank you for sharing the solution with us.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

Using ".*td title.*" for the regex would also have worked. The .* means any number of characters, so that full regex means "anything or nothing, followed by td title, followed by anything or nothing".


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Igor Mechnikov
Ranch Hand

Joined: Feb 13, 2011
Posts: 100

Rob Spoor wrote:Using ".*td title.*" for the regex would also have worked. The .* means any number of characters, so that full regex means "anything or nothing, followed by td title, followed by anything or nothing".


Excellent point.

Thank you.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

You're welcome.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: solved: (finding) matching regex pattern