I’ve a hunch the assumed ‘.numbers()’ might be a misunderstanding of String.toNumber(). The latter would not help here as your string contains an ad hoc mix of numbers and other characters. Indeed, the need for a regex in order to do meaningful query is the small of info that could be stored better.
You pattern is one or more numbers, possible space(s), hyphen (or other dash type?), possible space(s), one or more letters: ^(\d+) *\- *(\d+) *[A-Z]*$. If you aren’t prone to typos—most you are—you might use: ^(\d+)-(\d+).
I think @eastage’s suggestion makes a lot of sense. Rather than make regex mine out numbers from literal text, simply store the numbers you need. If concerned by the prospect of using two attributes, why not us a single List (so the order is maintained. For instance a user List attribute ‘ZoomRange’, and for you two examples the values would be:
There’s no right way but decades of data wrangling has taught me it’s easier to store the key bits you need (the numbers) and clothe them in extra text as needed. So:
function fLensAsLabel(iShort:number,iLong:number){
var:string vLabel;
if(iShort==iLong){
vLabel = iShort+" mm";
}else{
vLabel =iShort+"-"+iLong+" mm";
}
return vLabel;
} //end function
//usage
//[string] = fLensAsLabel($FocusShort,$FocusLong);
Thus:
By setting our agent to use $FocusShort and $FocusLong for the upper/lower bounds, we can test query:
Now you test query:
between($FocusShort,$FocusShort(agent),$FocusLong(agent))|between($FocusLong,$FocusShort(agent),$FocusLong(agent))
Plus, if we give our agent a Display Expression like so:
$Name+": "+$FocusShort+"–"+$FocusLong+" mm"
We get this result:
Here is the test document: lens-data1.tbx (115.2 KB)