cancel
Showing results for 
Search instead for 
Did you mean: 

Want to find "+" value from a variable

MurugarajSa
Deputy Chef III
Deputy Chef III

Hi,

I have 3 variables - Receiver, ISA07, ISA08

I will have to update ISA07 and ISA08 variables based on the value of Receiver.

if Receiver has value as 12+0975677. I need to validate whether receiver variable has "+" value. If so I will update ISA07=12 and ISA08=0975677. How to achieve it in formula mode.

Thanks

3 ACCEPTED SOLUTIONS

gary1
Executive Chef III
Executive Chef III

Try this:

For ISA07:

Receiver.include?("+") ? "12" : ISA07

For ISA08:

Receiver.include?("+") ? "0975677" : ISA08

If Receiver does not include "+" the variables will remain the same.

View solution in original post

Hi @MurugarajSa ,

You can use below formulae for the match 

ISA07:
Receiver.match?(/[\/+]/)? "12" : "ISA07" 

ISA08:
Receiver.match?(/[\/+]/)? "0975677" : "ISA08" 

 

 

View solution in original post

gary1
Executive Chef III
Executive Chef III

Will the Receiver value ALWAYS be "12+0975677" ? Or can the "12" and the "0975677" change? 

For example, if you received "99+7777777", you would expect ISA07 = "99" and ISA08 = "7777777" ?

If this is the case, then you need to do this a bit differently:

ISA07:

receiver.match?(/[\/+]/) ? receiver.split(/[\/+]/)[0] : isa07

ISA08:

 

receiver.match?(/[\/+]/) ? receiver.split(/[\/+]/)[1] : isa08

 

Credit to @shivakumara  for the regex

View solution in original post

6 REPLIES 6

gary1
Executive Chef III
Executive Chef III

Try this:

For ISA07:

Receiver.include?("+") ? "12" : ISA07

For ISA08:

Receiver.include?("+") ? "0975677" : ISA08

If Receiver does not include "+" the variables will remain the same.

MurugarajSa
Deputy Chef III
Deputy Chef III

Hi @gary1 

It worked perfectly. But

One concern is Receiver variable might have value "+" or "/". (E.g. 12+0975677,  12/0975677).

ISA07 should be 12 and ISA08 should be 0975677.

Can you please suggest me how I can achieve this?

Thanks in advance.

Hi @MurugarajSa ,

You can use below formulae for the match 

ISA07:
Receiver.match?(/[\/+]/)? "12" : "ISA07" 

ISA08:
Receiver.match?(/[\/+]/)? "0975677" : "ISA08" 

 

 

Hi @shivakumara 

Thanks