Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript find prototype 
Javascript :: react axios fetchData with loading screen plus API 
Javascript :: clean my react app 
Javascript :: add fraction in angular 
Javascript :: change the origin of html canvas 
Javascript :: vue trigger function after certain time 
Javascript :: jquery onchage html content 
Javascript :: javascript max characters string function 
Javascript :: reactnaviataion change title 
Javascript :: JavaScript - Closures 
Javascript :: how to loop through all tags in html 
Javascript :: javascript encrypt decrypt 
Javascript :: numbers split 2 
Javascript :: how to print elements in an array in javascript 
Javascript :: javascript latitude longitude to km 
Javascript :: ng-lazyload-image 
Javascript :: How to Subtract the numbers in the array, starting from the right in javascript 
Javascript :: react hotjar 
Javascript :: select class with data attribute jquery 
Javascript :: js remove trailling lines 
Javascript :: react fetch request with content type x-www-form-urlencoded 
Javascript :: javascript math 
Javascript :: Hide ReactTooltip after hover off 
Javascript :: how to copy all elements in an array except for the first one in javascript 
Javascript :: p5js no stroke 
Javascript :: Highest Scoring Word 
Javascript :: Find the Longest Word in a String 
Javascript :: fs renameSync 
Javascript :: jsx full form 
Javascript :: js recursive fetch 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =