Forum Discussion

CloudMe's avatar
CloudMe
Copper Contributor
Sep 28, 2019
Solved

Regex Question

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.
 
 
  • CloudMe 

     

    Would this work?

     

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

2 Replies

  • 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")
  • CloudMe 

     

    Would this work?

     

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