Deep-Learning icon indicating copy to clipboard operation
Deep-Learning copied to clipboard

What does the match function means?

Open Cc147 opened this issue 7 years ago • 3 comments

match = re.match(r'([A-Za-z_]+)(_[0-9]+.jpg)', file_name, re.I) What does this sentence mean?

Cc147 avatar Feb 01 '18 03:02 Cc147

This filters out two regex match groups from the filename: the file name and number, e.g. if you have files like dog_1.jpg, do_2.jpg, dog_3.jpg, etc., it filters out the _[number] from it and takes the file name (which is treated like the class name, so name the files like you named your classes in your label_map.pbtxt)

artus9033 avatar Feb 14 '18 22:02 artus9033

this isn't working, the match is showing NoneType. image

GShef avatar Aug 07 '18 05:08 GShef

patterns are grouped into parenthesis, match function searches and returns the match-object according to the aforementioned pattern string. Here first group says it consists of string pattern group in which each character can be either A to Z, or a-z or _ any number of times. Second group says it has to be started with _, then a string of characters each 0 to 9 any number of times, followed by '.jpg'

TejasReddy9 avatar Aug 07 '18 09:08 TejasReddy9