Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Extracting numbers between text.


Hello All,

Please help I have to extract number between text.

Example: my string contains B1234, B987HH etc I have to write a script to extract only number from the string.

String B9867HH to 9867

String B1234 to 1234

Thanks

1 Solution

Accepted Solutions
fernando_tonial
Valued Contributor

Re: Extracting numbers between text.

Hi, use the function PURGECHAR() or KEEPCHAR()

See.

PurgeChar('B9867HH','ABCDEFGHIJKLMNOPQRSTUWYVXZ') RESULT IS 9867.

or

KeepChar('B9867HH','0123456789') RESULT IS 9867.

Best Regards.

Tonial.

6 Replies
fernando_tonial
Valued Contributor

Re: Extracting numbers between text.

Hi, use the function PURGECHAR() or KEEPCHAR()

See.

PurgeChar('B9867HH','ABCDEFGHIJKLMNOPQRSTUWYVXZ') RESULT IS 9867.

or

KeepChar('B9867HH','0123456789') RESULT IS 9867.

Best Regards.

Tonial.

Not applicable

Re: Extracting numbers between text.

hi try this

purgechar ( 'a1b2c3','123' ) returns 'abc'

or try this

purgechar ( 'a1b2c3','abc' ) returns 123

Not applicable

Re: Extracting numbers between text.

Thanks a lot

MVP
MVP

Re: Extracting numbers between text.

Hi

Use:

KeepChar(myCode, '0123456789')

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
saumyashah90
Valued Contributor

Re: Extracting numbers between text.

Please check QVW

Not applicable

Re: Extracting numbers between text.

try this

keepchar ( 'B987HH','12345679' ) returns '123'

Community Browser