正则表达式问题 [英] Regex Question

查看:64
本文介绍了正则表达式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了它们存在之外,我几乎不知道正则表达式。但是,我知道这可能是我的同事问题的答案。


我们需要从某些数据中删除一些HTML。我们遇到的最大问题是< p>标签。但它们包括一些其他属性。例如:

I know almost nothing of Regular Expressions other than that they exist. However, I know that it''s probably the answer to my co-worker''s problem.

We need to strip some HTML out of some data. The biggest problem we have is the <p> tags. But they include some other attributes. For example:

展开 | 选择 | Wrap | 行号

推荐答案

我对RegEx一无所知意味着我的方式可能更蛮力。

获取<"的索引和>字符

丢弃之前的所有内容,包括第一个>并包括最后一个<<"
I know nothing of RegEx either meaning my way is probably more brute force.
Get the indexes of the "<" and ">" characters
Discard everything before and including the first ">" and after and including the last "<"


insertAlias,


在Python中:
insertAlias,

In Python:
展开 | 选择 | Wrap | 行号


@bvdet


正则表达式在整个语言中基本相同。
@bvdet
The regex will largely be the same throughout languages.


这篇关于正则表达式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆