相关疑难解决方法(0)

如何在Perl中找到正则表达式的所有匹配项?

我的表格中有文字:

Name=Value1
Name=Value2
Name=Value3
Run Code Online (Sandbox Code Playgroud)

使用Perl,我希望/Name=(.+?)/每次出现时都匹配并提取(.+?)并将其推送到数组上.我知道我可以$1用来获取我需要的文本,我可以=~用来执行正则表达式匹配,但我不知道如何获得所有匹配.

regex perl

21
推荐指数
3
解决办法
5万
查看次数

如何在Perl中从HTML中提取URL和链接文本?

我之前曾在Groovy中询问过如何做到这一点.但是,由于所有CPAN库,现在我在Perl中重写我的应用程序.

如果页面包含以下链接:

<a href="http://www.google.com">Google</a>

<a href="http://www.apple.com">Apple</a>

输出将是:

Google, http://www.google.com
Apple, http://www.apple.com

在Perl中执行此操作的最佳方法是什么?

html url perl parsing cpan

20
推荐指数
5
解决办法
3万
查看次数

解析,我在哪里可以了解它

我被赋予了将一种语言"翻译"成另一种语言的工作.对于使用正则表达式的简单逐行方法,源代码太灵活(复杂).我在哪里可以了解有关词法分析和解析器的更多信息?

parsing lex

17
推荐指数
4
解决办法
3785
查看次数

在Python中有效匹配多个正则表达式

当你有正则表达式时,词法分析器很容易编写.今天我想用Python编写一个简单的通用分析器,并提出:

import re
import sys

class Token(object):
    """ A simple Token structure.
        Contains the token type, value and position. 
    """
    def __init__(self, type, val, pos):
        self.type = type
        self.val = val
        self.pos = pos

    def __str__(self):
        return '%s(%s) at %s' % (self.type, self.val, self.pos)


class LexerError(Exception):
    """ Lexer error exception.

        pos:
            Position in the input line where the error occurred.
    """
    def __init__(self, pos):
        self.pos = pos


class Lexer(object):
    """ A simple regex-based lexer/tokenizer.

        See below for an example of …
Run Code Online (Sandbox Code Playgroud)

python regex lexical-analysis

14
推荐指数
3
解决办法
8230
查看次数

标签 统计

parsing ×2

perl ×2

regex ×2

cpan ×1

html ×1

lex ×1

lexical-analysis ×1

python ×1

url ×1