This is slightly more efficient:
REMatch( '[^]+|\S+' , value )
The difference is probably insignificant here, but as a general rule a negated
greedy match is a better choice than a wildcard lazy match.
(The second half is no different, just makes it more readable.)
if anyone else is looking for an answer to this we found the following regex
works perfectly:
REMatch('.+?|[^\s]+',value)
the only issue with this regular expression is if the user tries to
put any non-alphanumeric symbol in the string such as 'word-1' or
'word*1'.
how can i amend
Hi,
we have a string such as the following:
'word1 word2 word3 and word 4 word5 word6'
we need to split the string into an array with the following criteria:
- if any part of the string is inside double quotes then this is 1 array element
- else each individual word is 1 array element
You could Use REFind() to extract the strings in quotes first.
Then you can use ListToArray() on what's left
On Mon, Jun 27, 2011 at 4:33 PM, Richard White rich...@j7is.co.uk wrote:
Hi,
we have a string such as the following:
'word1 word2 word3 and word 4 word5 word6'
we need to split
thanks, the following works fine:
cfset result = REMatch('\w+|[\w\s]*','word1 word2 word3 and word 4 word5
word6') /
You could Use REFind() to extract the strings in quotes first.
Then you can use ListToArray() on what's left
the only issue with this regular expression is if the user tries to put any
non-alphanumeric symbol in the string such as 'word-1' or 'word*1'.
how can i amend the regular expression to allow for any of these characters:
we tried '[/w-/W]+|[\w\s-/W]*' but then it ignores the splitting on the
6 matches
Mail list logo