I'm trying to match a bunch of abbreviations that I'll need to extract or change in a list of data points. I believe I have a working solution but I would love to hear thoughts from more experienced regex users. The code will be written in JavaScript. Thanks for your help!
\b([CMKLPR]|PW|CCR|CS|CW|FG|G|Int|Jct|NOBO|NTH|P|PH|PO|PT|RG|Rx|SF|SOBO|SP|SR|TH|W|WMA|WMD)\b
Sample of the abbreviations (There are more)
C Camping
CCW Counter-clockwise
CG Campground (fee & potable water, unless otherwise indicated)
CR County Road
CS Convenience Store
CW Clockwise
FG Fire grate or grill
P Parking
G Grocery
This is what the data point strings look like
John Stretch Park at bicycle/pedestrian bridge. PW, R, PT, Day P, PH. NO CAMPING.
Edit To help clarify what I'm trying to do ....
I need to change this:
{
"Description": "Jct with 0.1-mile blue-blaze to Three Lakes Camp. C, RG, PT, W from pump.",
}
To Something Like this:
{
"Description": "Jct with 0.1-mile blue-blaze to Three Lakes Camp.",
"Amenities": [
{
"Title": "Camping",
"Icon": "camping.png"
},
{
"Title": "Register",
"Icon": "register.png"
},
{
"Title": "Picnic Table",
"Icon": "picnic.png"
},
{
"Title": "Water",
"Icon": "water.png"
}
]
}