[thelist] javascript / regex conundrum

Jeremy Weiss eccentric.one at gmail.com
Thu Oct 16 23:25:17 CDT 2008


I have a page that is currently displaying information on when an open house is scheduled. Unfortunately everything (date, time, comments, etc.) is in a single field. And there's no limit on how many events may be in the field. The client is wanting me to change the time values from 24 hour to 12 hour. And due to a long list of factors that I can't change, I have to do this in JavaScript.

Here's a sample of what could be in that field:

1 - Date:10/18/2008, Time:1300-1600, Type:PUB, Comment: 2 - Date:10/19/2008, Time:1300-1600, Type:PUB, Comment:';

Now, if I can get the '1300-1600' into a variable of its own, I can convert it. But I'm not sure how to pull it out or how to put the new value back. What I'm thinking is to do some regex magic to find all occurrences of "Time:" followed by "," and grab whatever is between them. Does that sound right? If so, I need help on the regex. I can find occurrences of "Time:" but I'm not sure how to grab only what follows it up to the next comma (without grabbing 'time:' or the comma).


-jeremy




More information about the thelist mailing list