Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
vardhan1305
Contributor II
Contributor II

In Between text

I need to create a column XXX where i should get the Number between the text.

I applied the logic TExtBEtween(name,'(',')') and i worked for just one scenario

Can anyone help me out.

id         state         name                                                  XXX

abc        BC       alb - ik me (abc def)(1234)                      1234

abc        BC       alb - ik me (abc def)(1234)                      1234

abc        BC       alb - ik me (1234)                                     1234

abc         BC      alb - ik me (1234)                                      1234



1 Solution

Accepted Solutions
neelamsaroha157
Specialist II
Specialist II

Try - KeepChar(name, '0123456789')

View solution in original post

6 Replies
neelamsaroha157
Specialist II
Specialist II

Try - KeepChar(name, '0123456789')

vardhan1305
Contributor II
Contributor II
Author

Hi Neelam. I got the output but sorry i forgot to write another scenario

id        state        name                                                  XXX

abc        BC      alb - ik me (abc def)(1234)                      1234

abc        BC      alb - ik me (abc def)(1234)                      1234

abc        BC      alb - ik me (1234)                                    1234

abc        BC      alb - ik me (1234)                                      1234

abc        BC      alb - ik me (pittsburgh)                          pittsburgh


I have 3 scenarios and can you suggest what to do in this scenario??



neelamsaroha157
Specialist II
Specialist II

So do you want the text/number between the last parenthesis??

vardhan1305
Contributor II
Contributor II
Author

Yeah.   alb - ik me "   is the name and if there is any number in the  parenthesis (1234) it should display the number or else " pittsburgh  ".


KeepChar(name, '0123456789')  worked for 2 scenarios and i need to apply for the other one too.

name                                                            XXX

   alb - ik me (abc def)(1234)                         1234

     alb - ik me (abc def)(1234)                      1234

    alb - ik me (1234)                                      1234

    alb - ik me (1234)                                      1234

    alb - ik me (pittsburgh)                           pittsburgh

santhana
Contributor III
Contributor III

Hi Harsha Vardhan   Kindly use the below code  it will meet your desired output

data:

load * Inline [

id      ,   state      ,   name                                                 

abc     ,   BC    ,   alb - ik me (abc def)(1234)                     

abc    ,    BC     ,  alb - ik me (abc def)(12345)                    

abc     ,   BC    ,   alb - ik me (12346)                                    

abc      ,   BC   ,   alb - ik me (1234)

abc      ,   BC   , alb - ik me (pittsburgh)    ];

load   

id,

state,

name ,

purgechar(subfield(name,'(',-1),')') as XXXX,

'*' as temp  Resident   data ;

drop table   data;




Thanks and Regards

Santhana Kumar

santhana
Contributor III
Contributor III

Hi use this


purgechar(subfield(name,'(',-1),')') as XXXX,