Is there always a space in between each number that you want to extract and the next text? IOW, if it is 854254sdfgf999, do you want it to be:
854254999 or 854254 999. If the first then you can use something like:
TrimAll ( Filter ( YourTextField; "0123456789 " ); 0; 0 )
Substitute ( TrimAll ( Filter ( YourTextField; "0123456789 " ); 0; 0 ); " "; ", " )
It will always be ###### some text here ###### ...
The only thing I can add is that the numbers will all be 6 digits.
I want a delimited list if all 6 digit numbers within the text...
Sent from my iPhone
Filter won't work because it doesn't respect the spaces. You just end up with a long string of numbers. I'm not good a recursion so my block headed-hard coded way would be something like this...
Substitute ( Trim ( Substitute ( "abab abba bbb 123454 aaa abb bba 675857 aba aab 494847" ; [ "a" ; "" ] ; [ "b" ; "" ] ; [ " " ; " " ] ; [ " " ; " " ] )) ; " " ; ", " )
You would have to expand it all the way out for all the characters besides nunbers that could exist. The subtitute in bold is 2 spaces and 3 spaces but that just depends upon how consistent the overall string is.
Hope this helps...
Pueblo System, Inc.
Not if you include the space in part of your filter like in my example.
I stand corrected! and i learned a new function TrimAll - Never saw that before!
1 of 1 people found this helpful
here you go ..
simple recursive custom function:
_Extract6Nums ( _Text ) ::=
_filterNumString = Filter ( _Text ; "0123456789" ) ;
_first6 = Left ( _filterNumString ; 6 ) ;
_rest = Middle ( _Text ; Position ( _Text ; _first6 ; 1 ; 1 ) + 6 ; 9999999999 )
If ( IsEmpty ( _Text ) ; "" ;
_first6 & ¶ &
_Extract6Nums ( _rest )
Well, I wrote my own recursive function before FileKraft posted his solution. Mine (optimized for my needs) looks like this:
values = WordCount ( text );
value = LeftWords ( text ; 1 );
number = GetAsNumber (value);
result = If (number > 0 ; number ; "");
nextResult = If (values > 1 ; ReturnNumberValuesFromText ( RightWords( text ; values-1) ) ; "");
return = If (Length(result)>5 ; result & ¶ & nextResult ; nextResult) // only interested in the 6 digit and longer values in my case...
now you re-specified it - and how about a little thanx to all the supporters?
Thanks to all who gave input. I spent some of Sunday working with the TrimAll and Filter options to see if they would be a more efficent method that my hastily composed recursive funciton. I learned a lot about these functions that I have not used to date.
In the end, I was worried that using these two functions would create errors down the road as the Filter function lumps the result into one large text string. It occurred to me on Saturday that the length of numbers in the input text would eventyally increase on length, and that human imput might result in smaller numbers being input as well (which would have to be ignored).
FileKrafts function works perfectly, and is more elegant than my function as long as the assumption of 6 digits is maintained. I am sorry that I "re-specified" problem. There is no way I could have explianed all of the possible constraints on the problem in a few lines.
As an aside, I took the opportuinity while writing my function on Saturday to introduce my 17 year old HS student to the concept of recursion.