How to select text between greater than and less than with an additional slash

2.5k Views Asked by At

I'm trying to select text between ></ . Example below I want "text"

>text</

but I'm unable to do so. tried the following but it doesn't like the slash at the end of the regex

\>(.*?)\<\

I'm trying to do this in TextPad. How is this supposed to be done? I'm ultimately wanting to delete all text between these two characters so all I'm left with is something like: <element></element>

3

There are 3 best solutions below

3
On

You are close.. use the following:

(>).*?(<\/)

And replace with \1\2

See DEMO

OR

You can use lookbehind and lookaheads:

(?<=>)(.*?)(?=<\/)

And replace with '' (empty string)

See DEMO

0
On

RegEx wise, you can use 3 groupings and for the replace only use the first and 3rd group: \1\3.

Find: (>)(.*)(</)   
Replace: \1\3
0
On

Try doing:

\>(.*?)\<\/

The regex that you were trying would actually have given error because you had a \ and nothing after that.