0

In GitHub I want to protect branches which have digits and dots. But if a branch has any letters, than it should not be protected

need fnmatch pattern so text with digits separated with dots will be matched

matched examples:

11.22
20.2
1.2.2.3.4

not matched examples:

abc_2.2

2.2_sss

1.9_AAA-1233
SuperStormer
  • 4,997
  • 5
  • 25
  • 35
VextoR
  • 5,087
  • 22
  • 74
  • 109

2 Answers2

3

The best way to do this, that is if you must use fnmatch, is to repeat the pattern. Code is follows

for i in range(1, 256): # github max branch name size 255
    fnmatch_pattern = '[0123456789.]'*i
    # whatever fnmatch function you want
    # append the result however you like. Note there will be duplicates

This is by far the best solution I can think of. Sorry if it's still so inconvenient.

jett8998
  • 888
  • 2
  • 15
0

I think this should work. Try this :- '^[0-9.]+$' --> Regex

?[0-9.?]+ --> fnmatch

Kumar Rishabh
  • 292
  • 1
  • 9