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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Find a string of a specific format within a field

Hi,

how can I search in a field for a string constituting an order_number which I need - to split it out and then see if the rest is usable.

The format is

>> S######## << (the letter S and 8 numbers)

There may be no BLANK inbetween or it might be something else - just this string.

It is in a field together with a lot of other stuff, the whole looks like this

SN 8638294 / 4 Stück / S80140915

Can anyone tell me how I could do this?

Thanks a lot!

Best regards,

DataNibbler

14 Replies
datanibbler
Champion
Champion
Author

Hi tresesco,

I think now I understand what you were proposing to do.

I guess I don't even have to loop through all the positions in the field if I change the order of those steps a little bit:

- First I will determine, by using the LEN() and Keepchar() functions, how often the letter S is in that field - the
  order_number always begins with an S.

- Then I will loop through those positions and

  - cut out 9 digits from each of those positions in turn

  - check whether the 2nd and 3rd digit in one of those cuts is numeric

Then I just have to find a way to reduce the field_to_be_processed_further by just those 9 digits in case I have found something looking like the order_nr.

That is another issue, however, and issues are there to be solved ...

Thanks a lot!

Best regards,

DataNibbler

anbu1984
Master III
Master III

Load String,Mid(String,Index(NewStr,'S00000000'),9);

Load *,Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(String,'1','0'),'2','0'),'3','0'),'4','0'),'5','0'),'6','0'),'7','0'),'8','0'),'9','0') As NewStr

Inline [

String

'SN 8638294 / 4 Stück / S80140915']

datanibbler
Champion
Champion
Author

Hi tresesco,

I have now found a way: Like I said, what I do is

- I find out how many times I have the letter "S" in that field

- I find out the positions of that letter

- From each of those positions in turn, I cut out a nine-digit-segment

- I check whether there are 8 numbers in that segment

  => In that case, there is an order_number in the field.

The next logical step would be to cut that order_number from that field so that only the remainder

of the field is moved on to further processing.

=> Can that be done? (I know the exact starting_position and length of the segment to cut out)

Thanks a lot!

Best regards,

DataNibbler

tresesco
MVP
MVP

May be like:

Left(Category,n-1)&Mid(Category,n+len)

n=starting_position

len=length of the segment to be cut off

datanibbler
Champion
Champion
Author

That is a good one.

I will try that.