开发者

how to express this in regex

I have this :

<title>Title</title>

All I want to do is express this in regex. I have:

/<[A-Za-z]>\w<\/[开发者_开发知识库A-Za-z]>

Can anyone help


You need a + after each of the [] and after the \w to represent "one or more".

/<[A-Za-z]+>\w+<\/[A-Za-z]+>/

But it looks like you're trying to parse HTML with regex. You might want to consider not doing that.


You should use a backreference. If you don't then you will match:

<title>blabla</otherTag>

Try this:

/<([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>(.*?)</\1>/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜