Extracting a number from a text fieldI have a column containing text notes entered by technicians. They enter the system usage hours, which I need to extract into it's own column. Fortunately, the data is pretty consistent, and so I have been able to pull the info out using Regex Match(), but selecting the last value is tripping me up.
Regex Match( :diagnosis, "(ys.+sage: ?)(\d{1,5})\n" );How do I extract the System Usage hours from the text block effectively?
Sample text looks like this:
UDI# 123456789123456789123456789456123
Device received, missing cover.
Major Reason For Service: xxxxxxxxxx
System usage: 2372
System PM due in: 7627
xxx usage: 120
yyy usage: 208
AnalyticsData TableRe: Extracting a number from a text fieldIf the data is consistent enough you could do this without regex by using Substr with Contains (and Length)
Names Default To Here(1);
text ="UDI# 123456789123456789123456789456123
Device received, missing cover.
Major Reason For Service: xxxxxxxxxx
System usage: 2372
System PM due in: 7627
xxx usage: 120
yyy usage: 208";
stringToSearch = "System usage: ";
sysUsage = num(Substr(text, Contains(text, stringToSearch) + length(stringToSearch), 4));
show(sysUsage);
Re: Extracting a number from a text fieldHere is a solution that uses JSL functions to extract the System Usage
Num( Word( 1, Substr( :Diagnosis, Contains( :Diagnosis, "System usage:" ) + 14 ), "\!n" ) )

I have attached the above data table