Skip to main content
18-Opal
March 21, 2022
Solved

SELECTING PATTERN OF NUMBERS

  • March 21, 2022
  • 2 replies
  • 1155 views

Lets say I had a column of numbers (5 digits)

71053

71187

12378

72678

My required function was

f(7,1,’x’,”x”,”x”) =710537 and 71187

f(“x”,2,”x”,”x”,”x”)=12378 and 72678

f(“x”,x,”x”,”x”,”8”)=12378 and 72678

f(“x”,x,”6”,”x”,”8”)= 72678

etc

 

What would be the best approach ?

Best answer by ttokoro

Step 1 Separate data for each digit.

ttokoro_0-1647914032679.pngimage.png

Step 2 Check the condition.

image.pngimage.png

2 replies

ttokoro
21-Topaz I
ttokoro21-Topaz IAnswer
21-Topaz I
March 22, 2022

Step 1 Separate data for each digit.

ttokoro_0-1647914032679.pngimage.png

Step 2 Check the condition.

image.pngimage.png

t.t.
25-Diamond I
March 22, 2022

Here is different approach.

The filter mask is provided as one single string, so there is no limit on number of digits in the data numbers or size of filter mask. To keep it all self-contained I found it better to provide the data vector as a second argument to the function.

The function assumes leading zeros for the numbers and treats any non-numeric character in the mask string as a wildcard (meaning "any digit").

Werner_E_0-1647964733923.png

P6 worksheet attached