cancel
Showing results for 
Search instead for 
Did you mean: 

Want to capture the part of the string.

Former Member
0 Kudos

Hi Experts,

I want a formula to capture a part of the string.

In a below line of strings i want to capture the part of text present within ( ) starting from right side of the string.

  • File(/data/logs/smsp/dbm_cdr.log) Monitor on APP-SMSP02(TD-Comviva-A2PSMSC-192.168.4.53):CRITICA
  • File(mor_cdr) monitor on SUFW03(TZ-Comviva-SUFW-172.27.55.166):NORMAL
  • Ping Monitor on a2p-smsc01 (CG-Comviva-A2PSMSC-191.168.2.86):MINOR

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

raghavendra_hullur
Active Contributor
0 Kudos

Hi,

Are those 3 lines will be 3 separate records? If so, try creating a formula with below content:

stringVar temp:= <your field with string value>;

stringVar temp1 := StrReverse(temp);

stringVar temp2:= mid(temp1, instr(temp1, ')')+1);

strReverse(left(temp2, instr(temp2,'(')-1))


Hope this is what you are looking for.

Thanks,

Raghavendra

Former Member
0 Kudos

Hi Raghavendra,

I tried using the formula given by you but am getting desired output.

i will explain my requirement once again.

In the below line i want to query the content between ( ) starting from right side.

File(mor_cdr) monitor on SUFW03(TZ-Comviva-SUFW-172.27.55.166):NORMAL

Please help me.

Thanks.

raghavendra_hullur
Active Contributor
0 Kudos

Hi,

I presume as per your original posting that, you want to extract TZ-Comviva-SUFW-172.27.55.166 from File(mor_cdr) monitor on SUFW03(TZ-Comviva-SUFW-172.27.55.166):NORMAL.

And I see that I am getting the extracted string value if I use the formula content I had provided earlier.

Let me explain further on the steps:

1. I created a formula with content as below (say formula name is string_val)

"File(mor_cdr) monitor on SUFW03(TZ-Comviva-SUFW-172.27.55.166):NORMAL"

2. I created another formula (say required_val) with below content:

stringVar temp:= @string_val; //@string_val contains the string value as in step 1.

stringVar temp1 := StrReverse(temp);

stringVar temp2:= mid(temp1, instr(temp1, ')')+1);

strReverse(left(temp2, instr(temp2,'(')-1))

3. I see that I am getting TZ-Comviva-SUFW-172.27.55.166 as output from required_val formula which is created in step 2.

Can you post what you are getting from the formula with content created in step 2?


Thanks,

Raghavendra