All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.
<!--- always sort first so the ranges make sense ---> <cfset numbers = listToArray("1,2,3,4,6,7,8,9,10,11,12,15,19,21,22")> <cfset arraySort(numbers, "numeric")> <cfset startAt = 1> <cfset maxPosition = arrayLen(numbers)> <cfset ranges = > <cfloop from="1" to="#maxPosition#" index="pos"> <!--- check difference between current and next number ---> <cfset offset = pos lt maxPosition ? 1 : 0> <cfset gap = numbers[pos+offset] - numbers[pos]> <!--- there was a jump in sequence OR this is the last element ---> <cfif gap gt 1 OR pos eq maxPosition> <cfif startAt lt pos> <!--- range ---> <cfset arrayAppend(ranges, numbers[startAt] &"-"& numbers[pos])> <cfelse> <!--- single value ---> <cfset arrayAppend(ranges, numbers[pos])> </cfif> <cfset startAt = pos + 1> </cfif> </cfloop> List of Ranges: <cfdump var="#arrayToList(ranges, ',')#">
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
6 Experts available now in Live!