Body Filter - RegExp

Moderator: crythias

Locked
drey284
Znuny newbie
Posts: 7
Joined: 26 Nov 2015, 17:45
Znuny Version: 5.0.3

Body Filter - RegExp

Post by drey284 »

Hello,

I need help tryind to figure out the correct regExp for an especific filter.
This is the message I need to parse:

"..reporte # 12345678 se ha..." and I need to capture "12345678" and save it in a dymanic field.

I've tried (among many others options)
Filter condition
Header 1 - Body Value 1 : "reporte # (\d{8})"
Set email headers
Header 1 - X-OTRS-DynamicField-HMNumber Value 1 - [***]

I've alse been using https://regex101.com/ to try to match the expression with what I need.

Hope you can help me.
Thank you very much.
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Body Filter - RegExp

Post by RStraub »

Start simple and see if you can match the numbers alone. Then extend the regexp.

Right now, my only idea would be to replace spaces with "\s" - I remember OTRS did have a problem somewhere with regexp and spaces.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
drey284
Znuny newbie
Posts: 7
Joined: 26 Nov 2015, 17:45
Znuny Version: 5.0.3

Re: Body Filter - RegExp

Post by drey284 »

Thank you very much,
It worked just fine by replacing spaces with \s.
I'll try the way you suggest adding properties to my other regEXP.

Thanks RStraub!
RStraub
Znuny guru
Posts: 2210
Joined: 13 Mar 2014, 09:16
Znuny Version: 6.0.14
Real Name: Rolf Straub

Re: Body Filter - RegExp

Post by RStraub »

Ohey, this was easy :) You're very welcome
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
drey284
Znuny newbie
Posts: 7
Joined: 26 Nov 2015, 17:45
Znuny Version: 5.0.3

Re: Body Filter - RegExp

Post by drey284 »

Hello, again, just for curiosity...

Looking for a better regular expression, nicer than the one I have

Text to parse--> "ant: name1 name2 name3 name4"

RegExp --> ant:\s(\w*\s\w*\s\w*\s\w*) (it works, but ick)

How can I express: from ":\s" to \n or \r ?

Thanks! :)
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Body Filter - RegExp

Post by reneeb »

\n or \r is

Code: Select all

[\n\r]
"[...]" is a so called character class
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Locked