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>/
精彩评论