Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
36
rated 0 times [  42] [ 6]  / answers: 1 / hits: 48796  / 13 Years ago, sat, april 23, 2011, 12:00:00

Given a string like:



Recipient: [email protected]
Action: failed
Status: 5.0.0 (permanent failure)
Diagnostic: No


How do I get the 5.0.0 and permanent failure only if it's always after Status: ? ?



Thanks


More From » regex

 Answers
181
var regex = /Status: ([0-9.]+) (([a-zA-Z ]+))/
var result = string.match(regex);
var statusNumber = result[1];
var statusString = result[2];


You should extend these: [0-9.], [a-zA-Z ] selectors if you expect other characters in these values. For now the first one expects numbers and dots, the second characters and spaces


[#92595] Thursday, April 21, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kieraelsies

Total Points: 718
Total Questions: 103
Total Answers: 104

Location: England
Member since Sun, May 21, 2023
1 Year ago
kieraelsies questions
Tue, Aug 3, 21, 00:00, 3 Years ago
Tue, Feb 23, 21, 00:00, 3 Years ago
Thu, Nov 12, 20, 00:00, 4 Years ago
Wed, Sep 9, 20, 00:00, 4 Years ago
Mon, Sep 16, 19, 00:00, 5 Years ago
;