Fix pascal_to_loudsnakes to handle repeated caps as single term.
This commit is contained in:
		
							parent
							
								
									8e3bcbc1af
								
							
						
					
					
						commit
						9e322c18d4
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		|  | @ -4,8 +4,8 @@ def pascal_to_loudsnakes(text): | ||||||
|     ''' |     ''' | ||||||
|     NoSuchPhoto -> NO_SUCH_PHOTO |     NoSuchPhoto -> NO_SUCH_PHOTO | ||||||
|     ''' |     ''' | ||||||
|     match = re.findall(r'[A-Z][a-z]*', text) |     text = re.sub(r'([a-z])([A-Z])', r'\1_\2', text) | ||||||
|     text = '_'.join(match) |     text = re.sub(r'([A-Z]+)([A-Z][a-z])', r'\1_\2', text) | ||||||
|     text = text.upper() |     text = text.upper() | ||||||
|     return text |     return text | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue