Validating Characters in Specific Positions

Hello everyone,

I'm encountering an issue with a specific function and I'm hoping someone can help me troubleshoot it. I know it should be very easy but I can' get out of it.
I'm trying to create a conditional statement in FileMaker to check if certain characters in a string are a period followed by two numbers. Here's the function I've been using:

If ( Middle ( "12.34.5678987654321" ; 6 ; 3 ) = ".##" ; 1; 0 )
result 0
Does it make sense?
Thank you all

Massimo

Assumed the dots beeing always at the same position:

Let ( [
	_dotAndDigits = ".0123456789";
	_testString = Middle ( "12.34.5678987654321" ; 6 ; 3 );
	_test = Length ( Filter ( _testString ; _dotAndDigits ) ) = 3
]
;	// Result
	_test
)
3 Likes

Thank you Mipiano
How is possible to know all this ? :sob: :sob: :sob: :sob: :sob: :sob:

2 Likes

Here's a slightly stricter variation of @mipiano 's good solution.

This version ensures the substring starting at position 6 starts with one dot and ends with two numbers

Let ( [
// TEST INPUTS
//	_input = "12.34...5678987654321" ; // bad
//	_input = "12.345678987654321" ; // bad
	_input = "12.34.5678987654321" ; // good

	_digits = "0123456789";
	// assuming we expect dot-digit-digit starting at the 6th character:
	_testString = Middle ( _input ; 6 ; 3 ) ;
	_test =
		Left ( _testString ; 1 ) = "." // starts with dot
		and Length ( Filter ( Right ( _testString ; 2 ) ; _digits ) ) = 2 // ends with two digits
] ;
	_test
)
5 Likes

Thank you. It was good the @Mipiano solution but actually the dot is a pain....
Thank you all.