aspose file tools
The moose likes Beginning Java and the fly likes Please help me interpret this pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Please help me interpret this pattern" Watch "Please help me interpret this pattern" New topic
Author

Please help me interpret this pattern

Jacob Sonia
Ranch Hand

Joined: Jun 28, 2009
Posts: 164
("<a\\b[^>]*href=\"[^>]*>(.*?)</a>")

I understand that * means 0 or more. [^] means negation, ? means 0 or 1, but i still cannot understand the whole pattern.

Thanks,
See
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Here you can lookup what the other characters mean. Just by scanning it it appears to match a html link tag <a href="something">Something else</a>


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

Joined: Oct 13, 2005
Posts: 32620
    
    4
Not too hot on regexes myself, but I think
Are you short of a second double-quote? You open quotes after href, but I can't see a closing quote.

That's what I can make of it. Let's see whether Rob has managed a better and quicker answer
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32620
    
    4
Wouter Oet wrote:Here you can lookup . . .
Good idea. Another place to look is the Pattern class.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

Campbell Ritchie wrote:Let's see whether Rob has managed a better and quicker answer

I would have split [^>]*href= into two separate parts, and would have explained the parentheses a bit more, but other than that it's a good explanation. And yes, a closing \" is missing.

These parentheses are probably actually used as a capturing group, allowing the user to get the hyperlink's label through the regex.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Please help me interpret this pattern
 
Similar Threads
5 Patterns
Numeric Format
Different Message Exchange Pattern interfaces
regexp question
Pattern Matching