Clean regex to match inner text

1k Views Asked by At

I'm parsing markup to match the inner text of tag elements using the following regex.

(?<=<*>)[^<]+(?=<[^>]*>)

I'd like to optimise this to remove matches on white space. eg: >space \n etc <

eg:

<div>
     <div>TargetMatch</div>
</div>

Targeted Hits:

  1. TargetMatch

Actual Matchs:

  1. " "
  2. TargetMatch

Any ideas?

Slyi

1

There are 1 best solutions below

0
On

Pattern: >\s+<

Replacement: ><