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

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...