我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用pyparsing.restOfLine()。
def getnewnick(sentence): """Parse detail to get new nick.""" nick = pp.Regex('[a-zA-Z0-9\-_|^]+').setResultsName('nick') parser = pp.Literal('is now known as') + nick + pp.restOfLine try: result = parser.parseString(sentence) return result.nick except pp.ParseException as x: pass