Could someone help me. I'm trying to parse this string using regex in javascript:
BMB-001 RING/MESH T-Bar Track T-BAR W/
My Goal is to match RING, MESH, T-BAR and W/ only.
I'm currently using this regex:
(\b[^\d\W][A-Z-'\/]['A-Z]+|\b[A-Z][-\/$]), But the result matched BMB, RING, MESH, T-B,T-BAR and W/
You can use
\b[A-Z]+(?:[-'][A-Z]+)*(?:\/|(?!\S))
See the regex demo. Details:
\b - a word boundary[A-Z]+ - one or more uppercase letters(?:[-'][A-Z]+)* - zero or more occurrences of - or ' and one or more uppercase letters(?:\/|(?!\S)) - a / or a location not immediately followed with a non-whitespace char.