0

I'm looking for a quick way to, for example, if this was my HTML document:

<!DOCTYPE html>
<html lang="en">
  <h1>Title</h1>
  <p>Hello</p>
  <p>This is a text line</p>
</html>

Select only Title, Hello and This is a text line all at once, ignoring the tags and non-string code.

Is there a keyboard shortcut or a plugin to do it? I'm working with MacOS on a Mac keyboard.

2 Answers2

0

I am not aware of any shortcut or plugin to do this but you could use a regular expression to replace all of the html tags with nothing:

Find '<[^>]*>'
Replace: ''

eg: https://regex101.com/r/zYb01t/1

Alternatively, if none of the content is hidden you could view the rendered html in a browser, select all ⌘A and copy all the text ⌘C.

Moob
  • 14,420
  • 1
  • 34
  • 47
0

You could use this regex:

(<\w+>)(.*)(<\/\w+>) as show for your code here. The parentheses group the output. What you want is group number two ( (.*) ). According to this post you can achieve this is VScode by using $2.

jschuebel
  • 312
  • 2
  • 15