cancel
Showing results for 
Search instead for 
Did you mean: 

replace < > () and parsing()

Former Member
0 Kudos

Q 1)

i have a content content , i want to eliminate the < > ( )

it works fine for < > but not ( )

i will get this if i include the ( ) ..pls advice

java.util.regex.PatternSyntaxException: Unclosed group near index 1

(

^

Q2)

if i want to write a method to get the mail address

xxxx@xxxx.com how to i write this method and store it in a string array...

String[] strAdd =parse(newstrContent);


public class test2 {

	public static void main(String[] args) {
String strContent="The original message was received at Mon, 9 Apr 2007 16:08:36 +0800" +
  "----- The following addresses had permanent fatal errors -----" +
  "<robinsonamerereee@hotmail.com>" +
  " ----- Transcript of session follows -----" +
  "... while talking to mx1.hotmail.com" +
  ">>> RCPT To:<robinsonamerereee@hotmail.com>" +
  "<<< 550 Requested action not taken: mailbox unavailable";
		
		String newContent=replace(strContent);
		System.out.println(newContent);
	}
	
private static String replace(String strContent){
String newstrContent = "";

newstrContent=strContent.replaceAll("<","");
newstrContent=newstrContent.replaceAll(">","");
//newstrContent=newstrContent.replaceAll("(","");
//newstrContent=newstrContent.replaceAll(")","");
System.err.println(newstrContent);
System.err.println("Mail Delivery Error Content:" +newstrContent.trim());
		return newstrContent.trim();
	}	

}

Message was edited by:

yzme yzme

Accepted Solutions (0)

Answers (1)

Answers (1)

prashil
Advisor
Advisor
0 Kudos

Hi Yzme,

Try to replace the following lines of code with ur commented lines:

newstrContent=newstrContent.replaceAll("//(","");

newstrContent=newstrContent.replaceAll("//)","");

Please reply if it gives any error.

Regards,

Prashil

prashil
Advisor
Advisor
0 Kudos

Hi Yzme,

Sorry i type the slashes incorrectly.

The // was actually
.

Hope this works.

Regards,

Prashil