Answers for "regex city and state"

0

regex city and state

// street, city and state must be separated by '.' or ','
const addressStr = '123 Main St., New York, NY 10001, USA';

const cityAndState = addressStr
						.match(/([A-Z][a-z]+\s?)+,\s[A-Z]{2}/g)
						.toString();

console.log(cityAndState);
// New York, NY
Posted by: Guest on April-23-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language