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*
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...