anno
anno

Reputation: 145

Compile pattern quote inside quote

So I need to compile a pattern that includes a set of " " inside it . It won't do the job any other pattern Using this pattern compare.

Pattern urlPattern = Pattern.compile("<div class="thumb"><a href=(.*?)-t1");

I am reading about it and you need to do something like "\stuff\" but I just can't work it in the pattern above. Any help?

Upvotes: 3

Views: 356

Answers (1)

Mena
Mena

Reputation: 48434

Escape your quotes:

Pattern myPattern = Pattern.compile("<div class=\"thumb\"><a href=(.*?)-t1");

Also, regex against HTML is usually considered to be bad practice.

Upvotes: 2

Related Questions