Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6931 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Any ideas how I would find the position of the first alphanumeric character in a string? For example, say I have the following 3 strings:

.......abc.....

..123..........

0..............

I need to find the position of a, 1, and 0 in each of the strings with a single calculation.

Thanks

Posted

Hi

I think that nobody can answer your question without some other informations !

1) What are those "........" ?

2) Where are those strings ( into one field or 3) ?

3) Which tipe of field/s it/they is/are ?

Posted

Those "........" are just part of the string, they are period characters. Any one field would contain just one string. I was just giving 3 separate examples. The field would be text.

Ultimately I need to do this...

I have a repeating filed with 20 reps. Some reps may be blank and some may not. For example:

rep1: blank

rep2: blank

rep3: data

rep4: blank

rep5: blank

rep6: data

rep7: blank

rep8: blank

rep9: blank

rep10: blank

rep11: blank

rep12: blank

rep13: blank

rep14: blank

rep15: blank

rep16: blank

rep17: blank

rep18: blank

rep19: blank

rep20: blank

I need to format the data from this repeating field in a way that allows it to shrink down for printing. However, I also need to maintain any leading blank spaces. Repeating fields won't shrink so I need to create a calc field that contains the info in the repeating field up to the last data value. So my calc field would be a text field that looks like this:

blank

blank

data

blank

blank

data

My thinking was to concatenate all of the repetions together into one big string while substituting blank reps with periods (or some other character). Then I would somehow find the first non-period character in the string and go from there. However, I think that that won't work now.

What will work I think though, is to still concatenate all reps while substituting blank reps with "x" for example. I'll also substitute all alphanumeric characters with "z" for example. I'll then find the 1st occurance of "z" from the right side of the string. That will tell me which rep is the last one to contain any data. Finally I can use MiddleValues to gather all the values of the repeating field up to the last data value.

I think I'm on the right track, but if someone has a better way I'd be happy to hear it.

Posted

Looks like this will do it. (Note that I'm only accounting for numeric characters in this example)

Let ([

list=

RepeatingField[1] & "¶" &

RepeatingField[2] & "¶" &

RepeatingField[3] & "¶" &

RepeatingField[4] & "¶" &

RepeatingField[5] & "¶" &

RepeatingField[6] & "¶" &

RepeatingField[7] & "¶" &

RepeatingField[8] & "¶" &

RepeatingField[9] & "¶" &

RepeatingField[10] & "¶" &

RepeatingField[11] & "¶" &

RepeatingField[12] & "¶" &

RepeatingField[13] & "¶" &

RepeatingField[14] & "¶" &

RepeatingField[15] & "¶" &

RepeatingField[16] & "¶" &

RepeatingField[17] & "¶" &

RepeatingField[18] & "¶" &

RepeatingField[19] & "¶" &

RepeatingField[20];

string=

Substitute(

RepeatingField[1] & "x" &

RepeatingField[2] & "x" &

RepeatingField[3] & "x" &

RepeatingField[4] & "x" &

RepeatingField[5] & "x" &

RepeatingField[6] & "x" &

RepeatingField[7] & "x" &

RepeatingField[8] & "x" &

RepeatingField[9] & "x" &

RepeatingField[10] & "x" &

RepeatingField[11] & "x" &

RepeatingField[12] & "x" &

RepeatingField[13] & "x" &

RepeatingField[14] & "x" &

RepeatingField[15] & "x" &

RepeatingField[16] & "x" &

RepeatingField[17] & "x" &

RepeatingField[18] & "x" &

RepeatingField[19] & "x" &

RepeatingField[20] & "x"

;["0";"z"]

;["1";"z"]

;["2";"z"]

;["3";"z"]

;["4";"z"]

;["5";"z"]

;["6";"z"]

;["7";"z"]

;["8";"z"]

;["9";"z"]

)];

MiddleValues (

list;

1;

20 - ( Length(string) - (Position(string;"z"; Length(string);-1) +1) )

)

)

Posted

Another way might be this:

Position ( theField ; Left(Trim(Substitute ( theField ; "." ; " " ));1) ; 1 ; 1 )

--sd

Posted

Piggybacking on Comment's Custom Function of MiddleRepetitions, and with a slight modification of his code to remove the Paragraph symbol,

GetRepetition ( repeatingField ; startRepetition ) &    //Removed "¶" &

If ( 

(startRepetition+1 ) <= endRepetition;

MiddleRepetitions ( repeatingField ; startRepetition +1; endRepetition ) 

)





you can use this calc to give you your result; leaving all spaces except those trailing at the end.





Let ( [  f= MiddleRepetitions ( random_text ; 1 ; 20 );

          m= MiddleWords ( f ; 2 ; WordCount ( f ) );

           p=Position ( f; m; 1; 1 ) -1;

           z= Left ( f ; p) ]; z & m

 )

This topic is 6931 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.