Security

How do I trim all characters starting from the first digit?

sshahmoon
New Member

I have a table and I want to trim the values for one field, such that all characters from the first digits onwards are removed
for example:

"dadmin01ldk" will be trimmed to "dadmin"

"rusl90" will be trimmed to "rusl",I have a table with a field.

I want to trim all characters starting at the first digit.

For example, "dadmin02yut" will be trimmed into "dadmin"

Tags (2)
0 Karma

493669
Super Champion

Try this regex-

|rex field=<yourfieldname> "^(?<String>[A-Za-z]+)"

It will trim and store result in String field

0 Karma

sshahmoon
New Member

this works!

thank you!

0 Karma

FrankVl
Ultra Champion

Try this, which captures all non-digits from the start of the field (replace 'yourfield' with the actual fieldname from your table):

| rex field=yourfield "^(<yourfield>\D+)"
0 Karma

sshahmoon
New Member

could not get it to work

table clienthost | rex field=clienthost "^(\D+)"

0 Karma

sandeeprachuri
Path Finder

@sshahmoon, FYI, Above rex works too. However, ? is missing in that regex. Try this,
| rex field=yourfield "^(?<yourfield>\D+)"

Thanks,
Sandeep

0 Karma

FrankVl
Ultra Champion

Ah, yes, my bad. Thanks for the correction.

0 Karma

sshahmoon
New Member

could not get it to work

table clienthost | rex field=clienthost "^(\D+)"

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...