Splunk Search

How to use rex on a QR String to cut out a part that I want

phamxuantung
Communicator

I have a QR String that when put in our custom QR divider can took it apart nicely. But I can't use the field extraction for this. How do I use custom rex. Example:

- My QR String:00020101021253037045405100005802VN38620010A0000007270132000697110001180003131000000032040208QRIBFTTA624101121000000032040821 ORD_6328416304A3AC

- The string I want to take out is 00069711000118000313100000003204 and 000697 (The first 6 characters) as field1 and field2.

Fortunately the 4 characters before and 4 characters behind don't chance.

Labels (2)
0 Karma
1 Solution

venkatasri
SplunkTrust
SplunkTrust

This should work.

| makeresults 
| eval str="00020101021253037045405100005802VN38620010A0000007270132000697110001180003131000000032040208QRIBFTTA624101121000000032040821 ORD_6328416304A3AC" 
| rex field=str "^\w+0132(?<field1>\S+)0208" 
| eval field2=substr(field1,0,6) | table field*

View solution in original post

venkatasri
SplunkTrust
SplunkTrust

Hi @phamxuantung 

Without boundaries pre-defined set of chars ahead or delimiter or pattern its tough to extract. For rex the user has to give an indication from where to start extracting and where to end boundaries.. 

0 Karma

phamxuantung
Communicator

hi @venkatasri 

The 4 characters before the string start always be 0132 and the 4 characters after the string end always be 0208. Will this be more feasible?

0 Karma

venkatasri
SplunkTrust
SplunkTrust

This should work.

| makeresults 
| eval str="00020101021253037045405100005802VN38620010A0000007270132000697110001180003131000000032040208QRIBFTTA624101121000000032040821 ORD_6328416304A3AC" 
| rex field=str "^\w+0132(?<field1>\S+)0208" 
| eval field2=substr(field1,0,6) | table field*
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...