Solved

another string substitution

Posted on 2002-06-12
2
170 Views
Last Modified: 2010-03-05
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
Comment
Question by:johnsm
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 7074113
$data =~ s/<[^>]*>//gi;
  or
$data =~ s/<.*?>//gi;
0
 
LVL 1

Author Comment

by:johnsm
ID: 7075488
Thanks. The second one was what I was looking for.

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to delete rows in a file based on the file name. 5 60
perl split by | 2 97
Executing multiple sybase statements in perl dbi 2 92
batch script for automated email 12 111
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question