Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试解析类名:
public class Script { }
我现在正在使用正则表达式,但它的效果不如我,我的正则表达式
class\s+(.*?)\W
但是,当诸如扩展和实现之类的东西出现时,它就会自我破坏。
我正在制作一个从 pastebin 下载源并自动保存的脚本。
谢谢。
这可以解决问题:
搜索除空格或括号之外的所有字符 class\s+([^\s{]+)\s*
class\s+([^\s{]+)\s*
尝试使用class\s+(\w*)\s*
class\s+(\w*)\s*
这也将处理类名class Classname{后没有空格的情况
class Classname{