Splunk Search

pls help with regular expression

DataOrg
Builder

i want to keep the pattern of specific word which starts with OS0003/SSED-BUS-0015 as it is and want to mask others numbers and email with "XXXX"

OS00194 - master Id: 1-56579333 Cancelled amazoon package

OS00194 - master Id: 1-56579333 Cancelled amazo0n package

P58U0040: record : First amazon package.

OS00178 - master Id: 0297276774 is
SSED-BUS-0000

..SSED-BUS-0000: ASEEM7593 micrsoft error
SSED-BUS-0015
..Action not allowed because airteel with value 377593df332

0 Karma

mayurr98
Super Champion

hey premranjithj

if you want to mask anything after Id: with Id: XXXX
then use below query

 | rex field=_raw mode=sed "s/Id:\s((\d+-\d+)|(\d+))/Id: XXXX/g"

If you want to mask : ASEEM7593 with : XXXX

| rex field=raw mode=sed "s/:\s[A-Z]+\d+/: XXXX/g"

If you want to mask value 377593df332 with value XXXX

| rex field=raw mode=sed "s/\w+$/XXXX/g"

If you want to mask P58U0040 with P58UXXXX

| rex field=raw mode=sed "s/P58U\d{4}/P58UXXXX/g"

If you want to mask any email in the data then use

| rex field=raw mode=sed "s/((\w[\w\-\.]+@\w+.com))(.*)/XXXX/g"

If you want to mask any email except your domain suppose gmail

| rex field=raw mode=sed "s/[A-z0-9._%+-]+@[A-z0-9.-]+\.[A-z]{2,63}(?<!@gmail.com)(?:[^A-z]|$)/XXXX/g"

Let me know if this helps you!

0 Karma

nikita_p
Contributor

Hi @ premranjithj,
Can you tell me exactly what data you want to extract from your events?

0 Karma

DataOrg
Builder

@nikita_p . i want the data to be masked as below.
example
OS00194 - master Id: 1-XXXX Cancelled amazon package
OS00194 - master Id: 1-XXXX Cancelled amazon package
P58UXXXX: record : First amazon package.
OS00178 - master Id: XXXXXXX is
SSED-BUS-0000
..SSED-BUS-0000: XXXXX micrsoft error
SSED-BUS-0015
..Action not allowed because airtel with value XXXXXX

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...