Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Created·2020-06-27 05:49
Flavor·JavaScript

/
\,(?=[^,]*$)
/
g
Open regex in editor

Description

Used this to dynamically create placeholder text when a user changed the coordinates format from default to custom. ex ['DD', 'DDM', 'DMS'] to remove the comma from the string. The format comes from an array of strings so I had to do a join(', ').replace(/,(?=[^,]*$)/g, ' or') to get DD, DDM or DMS

Submitted by anonymous