Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

extract a text from a string

Hi All!

I need to get the position inside a string from an specific text. For example

The field Tracking has the following content

0x|cam:0000|adg:0000|kwd:000

Any Idea how can I get the "adg:" position inside the string so I can later extract the number and save it as a niw field?

Regards

1 Solution

Accepted Solutions
richard
Partner - Creator
Partner - Creator

As Sunny T mentioned this is a good approach to the position of "adg:"

If you want the number behind "adg:" try:

=textbetween('0x|cam:0000|adg:0000|kwd:000','adg:','|')

View solution in original post

8 Replies
sunny_talwar

May be this:

=Index('0x|cam:0000|adg:0000|kwd:000', 'adg:')


Capture.PNG

richard
Partner - Creator
Partner - Creator

As Sunny T mentioned this is a good approach to the position of "adg:"

If you want the number behind "adg:" try:

=textbetween('0x|cam:0000|adg:0000|kwd:000','adg:','|')

puttemans
Specialist
Specialist

Hi Lucas,

Another possibility would be using 'Subfield', in the case that your field is built always the same way as you describe.

Subfield(Tracking, '|', 3) as Y will result in adg:0000

To select the number,

right(subfield(Tracking,'|', 3), 4) should give you the 0000 (will work if there are always only 4 numbers)

Regards,

Johan

Anonymous
Not applicable
Author

Thanks you all for your answers. All of them are useful, but this solution was the one who fit best my needs.

Regards!

sunny_talwar

Glad one of us was able to help you out

Anonymous
Not applicable
Author

@Richard

One more question. The textbetween worked perfectly, but didnt work for last component I wanted to extract. Probably because has no "|" at the end. This only happens in some raws. I mean, some of the raws has no "|" at the end, and others do have as they have more text before it,

In the following example Im tryng to extract the kwd info.

Example1. Works

0x|cam:0000|adg:0000|kwd:000|cid:000....

Example2 Didnt Work

0x|cam:0000|adg:0000|kwd:000

puttemans
Specialist
Specialist

Hi Lucas,

Subfield(Tracking, '|',4) will work in both occasions.

Regards,

Johan

richard
Partner - Creator
Partner - Creator

Hi Lucas,

If the code for the components can be max 4 digits you can try this:

=mid('0x|cam:0000|adg:0000|kwd:000',index('0x|cam:0000|adg:0000|kwd:000','kwd:'),'8')

As you see it's a combination of mid and index. The index function finds the starting text position of 'kwd:'