Building a Smart IDE: Programming Language Detection Discussions | Regex | HackerRank

Building a Smart IDE: Programming Language Detection

  • + 0 comments
    import re
    import sys
    
    content = sys.stdin.read()
    
    if re.match(r'.*?class [^{]+{', content, re.DOTALL):
        print('Java')
    elif re.match(r'.*?#include<', content, re.DOTALL):
        print('C')
    else:
        print('Python')