0

Take the following:

<span class='exclass'>1.</span> Lorem Ipsum <span class="exclass2" title="This is an example">*</span>

I am trying to create a regex expression that will select:

<span class='exclass'>1.</span>

AND

<span class="exclass2" title="This is an example">*</span>

Regex expressions like ^(<span(.*)<\/span>)$ select all of the text.

What expression will select the two complete tags and ignore the loose text between them? (Lorem Ipsum)

0

1 Answer 1

1

Regex is not good way to find HTML tags. But this should work for you-

<\s*span[^>]*>(.*?)<\s*\/\s*span>

DEMO: https://regex101.com/r/vbLN9L/6

Sign up to request clarification or add additional context in comments.

2 Comments

True. I didn't think of it as 'finding/selecting HTML tags' because one of those span tags was just appended onto a string I had stored in a js var beforehand. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.