Nati Cohen
Nati Cohen

Reputation: 230

Conversion of C#.Net Regex to Java Regex Pattern

I'm not a pro in Regex, therefore I'm having a difficulty translating this regex pattern to Java.

I believe it would be an easy task to a guy which is familiar enough with Regex. I have seen similar topics, however - each topic is relevant for a specific regex pattern...

The Pattern is:

@"\<meta name=""title"" content=""(?<title>.*)""\>"

Thanks in advance!

Upvotes: 1

Views: 475

Answers (1)

mpen
mpen

Reputation: 282845

If you want slashes in front of the openning and closing angle-brackets, use this (escaped for Java):

"\\\\<meta name=\"title\" content=\"(.*)\"\\\\>"

Without them, use this:

"<meta name=\"title\" content=\"(.*)\">"

Tested here using the unescaped version:

<meta name="title" content="(.*)">

Upvotes: 1

Related Questions