I’m trying to filter out the first comma and everything before it. Should I just use regex or will split work?
// notice multiple commas, I'm trying to grab everything after the first comma.
str = 'jibberish, text cat dog milk, chocolate, rainbow, snow',
// this gets the text from the first comma but I want everything after it. =(
result = str.split(',')[0];
Instead of split, try this – it will not mess with any other commas than the first
If you want to skip the leading space, use +2
If you are not sure there will always be a comma, it is safer to do trim