in reply to difference in regex
(After dropping up-votes on every single comment in this thread up to now ...)
If what you literally want to do is to “split the string by commas and take the last piece,” what I would probably have done is to first split the string on a comma, then pop the last entry off the resulting array. This will work whether-or-not there is actually a comma in the string, since in that case the array will contain only one entry. I would prefer this approach because it represents a literal interpretation of how you originally described your objective, and because it’s how I am accustomed to see this sort of thing being done most of the time. (The split function has many useful features – read the doc page in its entirety.)
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: difference in regex
by jwkrahn (Abbot) on May 29, 2018 at 18:26 UTC | |
| |
|
Re^2: difference in regex
by haukex (Archbishop) on May 30, 2018 at 13:32 UTC |