Splunk Search

Can you help me with my python regex expression?

stewiefre
New Member

I'm new in Python, so i have this string:

info1= "Jose Maria Almeida;00351 962341234;1997-12-19"

I'm trying to get the regex expression to that string and i got this:

('[a-zA-Z]+[ ]*([a-zA-Z^;]+);(^00351\s9\d{8}[^;]+$);(\d{4}-\d{2}-\d{2})+')

But when i check if it's valid, it says that it is not.

Could someone help me please?

Tags (2)
0 Karma

bmcaninch_splun
Splunk Employee
Splunk Employee

How about this one?

[a-zA-z]+.*;[0-9]+ [0-9]+;[0-9]+-[0-9]+-[0-9]+

https://goo.gl/D3Aw6b

0 Karma

stewiefre
New Member

Correct answer:
pattern = re.compile(r"^(?P^([A-Za-z]+\s)+[A-Za-z]+);(?P[0-9]+\s[0-9]+);(?P[0-9]{4})-(?P[0-9]{1,2})-(?P[0-9]{1,2}$)")

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...