J
J
Jekson2020-03-05 12:36:42
Regular Expressions
Jekson, 2020-03-05 12:36:42

Why doesn't regex validate?

There is such a regular
(SM-\d{1,}|Infrastructure|FIX) - \S.*

expression I try to send such a value
SM-38 - [FIX] - fix code style

but it does not accept

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Pankov, 2020-03-05
@Lepilov

(SM-\d+ - \[(Infrastructure|FIX)\]) - \S.*
https://regex101.com/r/FAaQ5b/1
In general, you did not provide enough cases for a normal answer.
Maybe this is more suitable for you:
(SM-\d+ - )?(\[(Infrastructure|FIX)\] - )?\s*.*
Here the ticket-id is optional and the commit type is optional and in extreme cases at least the text will be matched.
Although if a validator, then you probably want to. so that all commits are tied to tickets and marked with a type.

Z
Zolg, 2020-03-05
@Zolg

Because this is

SM-38 - [FIX] - fix code style
     ^^^

does not match regular

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question