+ Start a Discussion
Prakash Reddy 17Prakash Reddy 17 

Urgent help required for Formula

Here is my Scenario :
In Lead Object there is a LastName field contains  the name of a patient . for example John Readmit , Jack Readmit 2 , Jason Readmit3.
Using formula field , I need to display 1 if suppose LastName contains John Readmit ,display 2 if LastName contains Jack Readmit 2 and display 3 if LastName contains Jason Readmit3.

Formula Field is Number Data Type

I have  used the formulae IF( CONTAINS( "Re-Admit:re admit:readmit:Readmit:Re admit:ReAdmit:Re Admit:Re-admit", LastName), IF( CONTAINS( " 2", LastName), 2, IF( CONTAINS( " 3", LastName), 3, 1 ) ), null)

but it shows blank value.

Please help,

pavan kumar 177pavan kumar 177
Here's is the solution using REGEX that handles multiple spaces between words:


For an interval of n to m words inclusive, you would modify the repeater to be {n-1, m-1}... e.g. if you wanted 3 to 5 words, it would be 

We want the entire expression to evaluate to true (to throw the error) - so for NOT(REGEX(A,B)) we want string A to match expression B if A is a
valid input.


TRIM(Name) -> eliminate initial and ending whitespace from text area string
\S+ -> finds a 'word,' defined here by any character except whitespace, one or more times
\s+ -> followed by one or more whitespace characters
{n-1,m-1} -> repeat this n-1 to m-1 times
\S+ -> include the last word
Prakash Reddy 17Prakash Reddy 17
@Pavan Kumar :

Whenever User enters the LastName of Lead, the expected formula result would be below.
Expected  result --

John Readmit = 1
Jack Readmit 2 = 2
Jason Readmit3 = 3

Prakash Reddy 17Prakash Reddy 17
And also,
JohnTracer Readmit = 1
JohnTracer Readmit 2 = 2
JohnTracer Readmit 3 = 3