Dashboards & Visualizations

regex to not match number,character, space(between)

zacksoft_wf
Contributor

Need help with a regex to  show me if the input field has spaces at the leading or ending of the string OR if it contains " <doublequotes> anywhere in the string.

<change>
<eval token="validationResult" >if(match(value, "[^\"a-zA-Z0-9]"), "padded space or doublequote identified", "All Good"</eval>
</change>

Labels (1)
Tags (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust
(\s$|^\s|")

As simple as that - you match whitespace at the end OR whitespace at the beginning OR doublequotes just about anywhere. Just remember to do proper backslash-escaping.

0 Karma

zacksoft_wf
Contributor

It's not working .

=============================================
<form>
<label>TextBox Validation</label>
<fieldset submitButton="false">
<input type="text" token="selText">
<label>Enter your Input (Dont add heading or trailing space or double quotes)</label>
<change>
<eval token="validationResult">if(match(value, "(\s$|^\s|")), "Space Padding or double quote identified", "No Error Identified"</eval>
</change>
</input>
</fieldset>
<row>
<panel>
<table>
<search>
<query>| makeresults
| eval Text="$selText$ has $validationResult$"
| table Text</query>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">20</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">cell</option>
<option name="percentagesRow">false</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
</panel>
</row>
</form>

=============================================

0 Karma

PickleRick
SplunkTrust
SplunkTrust

"Just remember to do proper backslash-escaping."

You'd probably need to do something like

(\\s$|^\\s|\"))

In order to escape the regex as a string

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!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...