can we join 2 HTML pattern in one input?

I have this pattern in HTML for an ID login :

[0-9]{6} (need 6 numbers)

and i just learned some users have a letter before numbers so it became :

^(a|A)([0-9]{6})$

and i want to know if it's possible to join the two pattern in one (write 6number or 1 letter + 6 numbers)?

2 answers

  • answered 2018-05-16 06:39 Hugo

    Yes, you can join the two patterns with the "|" character. Please, try this: [a-z]{1}\d{6}|[A-Z]{1}\d{6}

  • answered 2018-05-16 06:41 Michael Townshend

    ^(a|A)?([0-9]{6})$

    By adding the ? we are saying the first capturing group must appear either zero or one time.

  • Search for the closest match in a list of numbers (Pattern Recognition)

    Need help for a Python project - my algo generates a big list of numbers that represent the duration of events and their type, depending on the type they can be represented in either positive or negative numbers. Looks like this:

    Pattern_Num = [23, -6, 18, -9, 6, -20, 3, -6, 8, -7, 12, -5, 8, -13, 16, -17, 25, -6, 9, -14, 6, -5, 11, -1, 9, -4, 31, -3, 26, -7, 25, -2, 3, -6, 23, -4, 5, -4, 14, -2, 19, -3, 11, -12, 14, -6, 3, -22, 6, -19, 10, -26, 4, -8, 3, -9, 2, -4, 9, -3, 6, -21, 9, -15, 6, -9, 4, -19, 3, -17, 7, -2, 15, -3, 25, -4, 4, -4, 20, -3, 11, -7, 8, -14, 4, -3, 14, -6, 7, -18, 4, -3, 10, -8, 4, -15, 4, -8, 23, -7, 6, -3, 12, -2, 13, -4, 5, -10, 5, -5, 13, -2, 11, -10, 4, -2, 20, -2, 2, -7, 3, -3, 4, -5, 7, -13, 7, -21, 7, -2, 14, -2, 12, -7, 6, -11, 2, -3, 11, -3, 9, -14, 4, -12, 4, -2, 6, -9, 4, -17, 3, -4, 4, -10, 14, -9, 2, -3, 4, -2, 8, -6, 3, -3, 9, -5, 3, -30, 4, -5, 5, -10, 2, -8, 3, -5, 7, -18, 11, -6, 2, -17, 11, -9, 4, -6, 25, -13, 3, -2, 9, -4, 2, -2, 12, -4, 2, -4, 7, -3, 10, -17, 4, -2, 4, -1, 4, -1, 18, -5, 5, -3, 3, -10, 9, -10, 9, -4, 5, -3, 5, -4, 4, -2, 2, -9, 8, -6, 15, -6, 8, -2, 14, -3, 4, -4, 10, -2, 5, -1, 4, -18, 6, -9, 3, -4, 6, -2, 19, -17, 3, -12, 9, -2, 11, -6, 19, -3, 2, -5, 7, -5, 4, -10, 7, -2, 3, -15, 9, -8, 12, -6, 7, -2, 4, -2, 8, -1, 8, -2, 7, -5, 6, -2, 5, -38, 4, -2, 4, -1, 5, -1, 4, -6, 3, -5, 2, -6, 3, -3, 6, -2, 9, -11, 5, -17, 7, -3, 4, -2, 8, -2, 12, -8, 13, -3, 4, -20, 6]
    

    What needs to happen next is the program to start searching inside the whole list for the closest repeating sequence of the last 3 digits in the same order. In this case the last 3 digits are '4, -20, 6' . IF no result is found with the exact numbers the program should perform a second search that accepts matches that allows deviation of +-1 for each number from the sequence(so 3,-19,5 and 5,-21,7 will both be a match), IF again no match is found it starts looking for +-2 and finally +-3.

    If anyone can help me out or guide me to what I should learn(haven't found resource that specifically shows something similar) to do it myself would be super grateful.

  • how to find a file of certain regular expression exists on http Url location using java

    I have http url location which has multiple files ,Using java how can I check if a file of certain pattern exists at that url location with a head request.

  • complex Find and replace using regular expression

    I have created a new function which is to be replaced multiple times

    original func call: fun_x(fun_y("param1","param2","param3"),...);

    new func call:

    fun("param3",...);

    So I want to remove param1 and param2 and make param3 as first param and whatever arglist pass it as second onward param.

    Any idea will be helpful as I have to replace it like 1000 times.