Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
JustTryingToLearn
Contributor III
Contributor III

Pulling a substring out of an inconsistent string

I have a substring I need that is embedded withing a larger string. The sting follows this fomat:

ABC 1234 Microsoft (need to extract 1234)

DEF Q7 1234 Android (Need to extract 1234)

GHI H3 1234 Apple34 (Need to extract 1234)

The string I need to extract is always 4 numbers long and has either 3 letters in front of it with a space or 3 letters, a space, a letter and a number, and another space. The string after the space is always inconstant and can contain letters and numbers.

 

Is there an expression that can pull the substring out?

 

Thank you

2 Replies
jwjackso
Specialist III
Specialist III

Using the data below:

Data:
load Str,
If(IsNum(SubField(Str,' ',2)),SubField(Str,' ',2),SubField(Str,' ',3)) as N;
Load * Inline [
Str
'ABC 1234 Microsoft'
'DEF Q7 1234 Android'
'GHI H3 1234 Apple34'
];

 

1234.PNG

JustTryingToLearn
Contributor III
Contributor III
Author

Thank you for the response! Would this work if there were thousands of entries? Is there a way to do it without listing them all? I am pulling this data in as a dimension.

 

Also, is this possible to do with a calculated field?