This activity accompanies the second case study in Unit 11, on the Google SOAP API.
As this API has now been withdrawn by Google, this activity remains here only for illustration.
Before executing the program you will need to obtain a key and paste it into the program at the point indicated by the line
search.setKey("Key needed here");
This involves creating a Google account. Details of how to do this can
be found at the
create a Google account link
If you have problems finding this page, just use Google to search with the keywords "Google" "api" and "Java".
Once you have run the program, modify it so that when it finds the text corresponding to the regular expression not only the string "Found" is emitted but the string that has been found is displayed after "Found".
In order to do this you will need to use the getParen method (with argument 0) from the class RE, this will return the matched string; for example the code
String foundString = searchPattern.getParen(0)will place in the variable foundString the substring that has been matched to the regular expression searchPattern.
If some classes are not found, you will need to add the jars containing the Google api and regular expressions classes:
googleapi.jar
All the classes that you need will then be made available to your project.