• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

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.
0
johnsm
Asked:
johnsm
1 Solution
 
ozoCommented:
$data =~ s/<[^>]*>//gi;
  or
$data =~ s/<.*?>//gi;
0
 
johnsmAuthor Commented:
Thanks. The second one was what I was looking for.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now