Regexp multiline option
Hello Support,
I would like to implement regular expression validator for multi line text field "source" to check if the users are providing properly ip addresses. I found that my regexp is working only for one line even if I marked the multiline. Could you take a look?
Do you have any idea how to check it only for selected issue type without having separate workflow?
Please find attached prtscns.
Comments (7)
-
repo owner -
reporter No luck with "Dot All"
Exactly one ip address per line.
-
repo owner Hi Hubert,
Try the following regular expression:
^(\s*\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s*(\n|$))+
Check "Dot All".
-
reporter Hi Fidel,
Perfect, it works! Just one more question is it possible to check it only if certain condition is fulfilled in example field value or issue type?
Cheers, Hubert!
-
repo owner Hi Hubert,
You can use Boolean validator with math, date-time or text-string terms validator with a boolean expression like this one:
%{00014} in ["New Feature", "Improvement"] IMPLIES matches(%{nnnnn}, "(?s)^(\\s*\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\s*(\\n|$))+")
replacing nnnnn with field code in field Source.
In the example expression we are only requiring the IPs to be entered when issue type is "New Feature" or "Improvement".
Note that %{00014} is field code for Issue type.
-
reporter Hi Fidel,
You are the best it works like a charm! I even modify it a bit to check if it's proper ip address restricted to 255:
%{00014} in ["Network Firewall Changes"] IMPLIES (matches(%{15290}, "(?s)^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/\\d{1,2})?\\s (\\n|$))+") and matches(%{15656}, "(?s)^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/\\d{1,2})?\\s*(\\n|$))+"))
thx for the IMPLIES I wasn't aware of it :) Cheers, Hubert
-
repo owner - changed status to resolved
Thanks your your words. Have a nice weekend.
- Log in to comment
Try checking "Dot All" mode.
Which is exactly the content you want to validate in the field Source? One IP address per line?