another string substitution

How do I write a line of code that will get rid of my html tags leaving only my text?

If my data is:
--------------
$data = "<a href=whatever class=x>my text</a>

How do I write this line?
-------------------------
$data =~ s/ / /gi;

to get:
-------
$data = my text

I tried:

$data =~ s/<(.*)>//gi;

but that doesn't seem to work. It just wipes out the whole line leaving $data = "".

Thanks.
LVL 1
johnsmAsked:
Who is Participating?
 
ozoConnect With a Mentor Commented:
$data =~ s/<[^>]*>//gi;
  or
$data =~ s/<.*?>//gi;
0
 
johnsmAuthor Commented:
Thanks. The second one was what I was looking for.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.