SOLVED

Regex Question

Occasional Contributor

Hi,

 

How can i extract a single value from a string:

 

ABC XXXXX DEF

 

I know my XXX value will always be between ABC and DEF but i can't find a way to extract it without extracting the ABC and DEF as well.   extract("ABC .+ DEF"

 

Is there a way to only extract the .+ and ignore the rest?
 
Thank You.
 
 
2 Replies
best response confirmed by CloudMe (Occasional Contributor)
Solution

@CloudMe 

 

Would this work?

 

print t= "ABC XXXXX DEF"
| parse t with *"ABC" theInfo "DEF"*
| project theInfo 

@CloudMe In Regex wrap the .+ in parenthesis to assign it to a capture group. Then you can use the optional extract parameter captureGroup:

 

print extract("ABC (.+) DEF", 1, "ABC XXXXX DEF")