Say I had a string that always had a two letter identifier such as ID or XX, or another variant. The only thing that is consistent is that the identifier is two capital letters.
eg: Half, ID, Acre
Is it possible to only add a <br/> after the ID part of the string with jQuery?
eg Half, ID,<br/> Acre
If it’s string manipulation you’re after you’d use plain JavaScript, not jQuery.
The following adds
"<br/>"after any instance of two capital letters in a row followed by a comma:If you also wanted to allow for two capitals at the end of the string with no trailing comma then you could use the following regex instead:
If you only want to do the first one, e.g., only change
IDwithin"Half, ID, XY, ZZ, Acre"just remove thegflag from the end of the regex.