Java tutorial
//package com.java2s; import javax.annotation.Nonnull; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { @Nonnull public static String stripComments(@Nonnull String source) { Pattern pattern = Pattern.compile("#(.*)"); Matcher matcher = pattern.matcher(source); return matcher.replaceAll(""); } }