Find last occurrence of comma in a string using regex in javascript
问题 I have a string which represents an address in Javascript, say, "Some address, city, postcode". I am trying to get the 'postcode' part out. I want to use the split method for this. I just want to know a regex expression that will find the last occurrence of ' , ' in my string. I have tried writing expressions such as address.split("/\,(?=[^,]*$)/"); and address.split(",(?=[^,]*$)"); But these don't seem to work. Help! 回答1: pop() will remove the last element of an array: address.split(",").pop