-5

I have a string like

1372110902.747405 29245 verbose [paymentserv]: === AUTH: ExternalFundingAnalysisStage was successful (rc:0) ===

i want only

AUTH: ExternalFundingAnalysisStage was successful (rc:0) 

using regular expression. please help me to sort out the issue.

Thanks in advance

3

4 Answers 4

2

Using PHP:

$var = "1372110902.747405 29245 verbose [paymentserv]: === AUTH: ExternalFundingAnalysisStage was successful (rc:0) ===";
$var = preg_replace("@.*===([^=]+)===.*@i",$1,$var);
2

Since you didn't specify which language you are using your regex in, any language is presumably a valid response. So, in Perl, you could use the substitution:

s/.*=== (.*) ===.*/$1/;

or the match:

m/=== (.*) ===/;

After the match, $1 will contain the string you wanted to find.

The .* after the second === in the substitute is unnecessary for the sample line of input, but is symmetric with the .* at the beginning of the regex, and symmetry is pleasing. It protects the substitute command from trailing debris; the match doesn't need the protection.

0
0

If it's always going to be along the same lines (beginning with AUTH, ending with (rc:#)):

//JavaScript
var str = "1372110902.747405 29245 verbose [paymentserv]: === AUTH: ExternalFundingAnalysisStage was successful (rc:0) ===";
str = str.slice(str.indexOf("AUTH"), str.lastIndexOf(")")+1);

Or with a regex:

str = str.replace(/^.+={3}\s(.+)\s={3}$/,"$1");
0

for that you also use java regex for detail follow this Tutorial and in your case you can also use sub-string .

Like:

String str ="1372110902.747405 29245 verbose [paymentserv]: === AUTH: ExternalFundingAnalysisStage was successful (rc:0) ==="; 

String str1=str.subString(58,106);
Stirng str2=str.replace("(","");

Then you get your required answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.