SOLVED

Regex Question

%3CLINGO-SUB%20id%3D%22lingo-sub-880570%22%20slang%3D%22en-US%22%3ERegex%20Question%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-880570%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20can%20i%20extract%20a%20single%20value%20from%20a%20string%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EABC%20XXXXX%20DEF%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20know%20my%20XXX%20value%20will%20always%20be%20between%20ABC%20and%20DEF%20but%20i%20can't%20find%20a%20way%20to%20extract%20it%20without%20extracting%20the%20ABC%20and%20DEF%20as%20well.%26nbsp%3B%20%26nbsp%3B%3CSPAN%3Eextract(%22ABC%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B.%2B%20DEF%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EIs%20there%20a%20way%20to%20only%20extract%20the%20.%2B%20and%20ignore%20the%20rest%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EThank%20You.%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-880570%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EQuery%20Language%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-880792%22%20slang%3D%22en-US%22%3ERe%3A%20Regex%20Question%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-880792%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F409040%22%20target%3D%22_blank%22%3E%40CloudMe%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWould%20this%20work%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Eprint%20t%3D%20%22ABC%20XXXXX%20DEF%22%0A%7C%20parse%20t%20with%20*%22ABC%22%20theInfo%20%22DEF%22*%0A%7C%20project%20theInfo%20%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-909621%22%20slang%3D%22en-US%22%3ERe%3A%20Regex%20Question%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-909621%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F409040%22%20target%3D%22_blank%22%3E%40CloudMe%3C%2FA%3E%26nbsp%3BIn%20Regex%20wrap%20the%20.%2B%20in%20parenthesis%20to%20assign%20it%20to%20a%20capture%20group.%20Then%20you%20can%20use%20the%20optional%20extract%20parameter%20%3CEM%3EcaptureGroup%3A%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Eprint%20extract(%22ABC%20(.%2B)%20DEF%22%2C%201%2C%20%22ABC%20XXXXX%20DEF%22)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
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")