I have a regex that I thought was working correctly so far. I need to match an optional character. He may or may not be there.
Here are two lines. The top line is matched, but the bottom is not. The absence of a single letter in the bottom line is what makes it unsuccessful.
I would like to receive one letter after the starting 5 digits, if there is one, and if not, continue to receive the rest of the line. This letter may be AZ .
If I delete ([AZ]{1}) +.*? + ([AZ]{1}) +.*? + from a regular expression, it will match everything I need, except for the letter, but this is important.
20000 K Q511195DREWBT E00078748521 30000 K601220PLOPOH Z00054878524
Here is the regex that I use.
/^([0-9]{5})+.*? ([AZ]{1}) +.*? +([AZ]{1})([0-9]{3})([0-9]{3})([AZ]{3})([AZ]{3}) +([AZ])[0-9]{3}([0-9]{4})([0-9]{2})([0-9]{2})/
operators string regex
jim Oct 24 2018-10-10T00: 00-10
source share