K
kaeli
Hey all,
I'm rather new to the java regular expressions package. I must be doing
something wrong. The following code outputs false, false, and no match
exception. Why? It should match (m.group() expected to return <title>
this is a title</title>). TIA
import java.io.*;
import java.util.*;
import java.util.regex.*;
public class testPatternMatching extends Object
{
public static void main(String [] args)
{
String pageContent = "some text blah <title>this is a title
</title> more text blah";
String title = null;
try
{
Pattern p = Pattern.compile("<title>.*</title>",
Pattern.DOTALL);
Matcher m = p.matcher(pageContent);
System.out.println(m.lookingAt());
System.out.println(m.matches());
title = m.group();
System.out.println(title);
}
catch (Exception e)
{
System.out.println("Exception occured:");
System.out.println(e.getMessage());
}
}
};
--
--
~kaeli~
I love God.
It's His fanclub that I can't stand.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
I'm rather new to the java regular expressions package. I must be doing
something wrong. The following code outputs false, false, and no match
exception. Why? It should match (m.group() expected to return <title>
this is a title</title>). TIA
import java.io.*;
import java.util.*;
import java.util.regex.*;
public class testPatternMatching extends Object
{
public static void main(String [] args)
{
String pageContent = "some text blah <title>this is a title
</title> more text blah";
String title = null;
try
{
Pattern p = Pattern.compile("<title>.*</title>",
Pattern.DOTALL);
Matcher m = p.matcher(pageContent);
System.out.println(m.lookingAt());
System.out.println(m.matches());
title = m.group();
System.out.println(title);
}
catch (Exception e)
{
System.out.println("Exception occured:");
System.out.println(e.getMessage());
}
}
};
--
--
~kaeli~
I love God.
It's His fanclub that I can't stand.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace