Timeline for Separating values in string and returning them as comma separated string
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 18, 2014 at 16:45 | comment | added | Flambino | @Skarven updated my answer with some more info | |
Sep 18, 2014 at 16:45 | history | edited | Flambino | CC BY-SA 3.0 |
added 1262 characters in body
|
Sep 18, 2014 at 16:32 | comment | added | Flambino |
@Skarven Ah, no the current regex would not match those (firstly because it starts with a digit, and secondly because it doesn't match spaces or periods either). However, this should work /([^#]*?)[a-z][^;]*/ig (it matches everything between a # and a ; as long as at least 1 letter is involved). At some point, though, if the regex has to be exceedingly complex, you're probably better off going back to splitting the string (and possibly filtering the result)
|
|
Sep 18, 2014 at 16:16 | comment | added | Skarven | Brilliant, I appreciate your in-depth response, advices and solution. There could be cases where the actual values also contain numbers (Such as "68;#1. Preperation;") for ordering purposes. Would your one-liner keep these numbers, and if not - how can this be taken into consideration? | |
Sep 18, 2014 at 15:31 | vote | accept | Skarven | ||
Sep 18, 2014 at 14:21 | history | edited | Flambino | CC BY-SA 3.0 |
added 262 characters in body
|
Sep 18, 2014 at 11:36 | history | edited | Flambino | CC BY-SA 3.0 |
added 1132 characters in body
|
Sep 18, 2014 at 8:26 | history | answered | Flambino | CC BY-SA 3.0 |