Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Sagar082
Creator
Creator

Extraction of string from other string

Hi everyone,

Greeting for the day. I would like to understand, what I'm committing mistake in below formula;

mid([Message],Index([Message], '.',1)-2,(Index([Message], ' ', Index([Message], '.',1))-Index([Message], '.',1))+2)

the formula Index([Message], '.',1); is calculating correctly.

Whereas,  Index([Message], ' ', Index([Message], '.',1) is not correctly identifying position. It is not starting the search from the position of Index([Message], '.',1)

for e.g.

abcdefghi xxx.xx.xx.xx ncaf

which should result xxx.xx.xx.xx.

So, the Index([Message], '.',1) returns the position 11, which is correct. Whereas Index([Message], ' ', Index([Message], '.',1) which should return the position 19, but it returns 72.

I believe I'm committing some logical error. 

Can someone help me to correct it.

Regards,

Sagar.

1 Solution

Accepted Solutions
Sagar082
Creator
Creator
Author

Hi everyone,

Greeting for the day.  I found the solution to above problem,

mid([Message],Index([Message], '.',1)-2,(FindOneOf([Message], ' ', 2)-Index([Message], '.',1))+2)

FindOneOf  help to find the occurrence of the char_set in text. I had ask to search second Occurrence.

I hope this will help someone, who is in need.

Regards,

Sagar.

View solution in original post

2 Replies
Chanty4u
MVP
MVP

Hi,

Not sure but try this.

Tab:
load *,
KeepChar(string,'x.') as result;
load * Inline[
string
abcdefghi xxx.xx.xx.xx ncaf
];

exit SCRIPT;

keep.PNG

Sagar082
Creator
Creator
Author

Hi everyone,

Greeting for the day.  I found the solution to above problem,

mid([Message],Index([Message], '.',1)-2,(FindOneOf([Message], ' ', 2)-Index([Message], '.',1))+2)

FindOneOf  help to find the occurrence of the char_set in text. I had ask to search second Occurrence.

I hope this will help someone, who is in need.

Regards,

Sagar.