?
Solved

how do I remove this string

Posted on 2006-07-22
4
Medium Priority
?
162 Views
Last Modified: 2010-03-05
Hi Everyone.
I am having trouble figuring out how to remove a string from a text file.  If someone could help I would really appreciate it.  Below is a css that I have and I need to remove the "position:relative" from each of the "a" tags and leave the rest alone.

input {
      position:relative;
}

iframe {
      position:relative;
}
button {
      position:relative;
}

a { color: white;
      font-size: 12px;
      font-weight: bold;
      text-decoration: none;
      position:relative;
}

a:hover { color: silver !important;
      font-size: 12px;
      font-weight: bold;
      text-decoration: none;
      position:relative;
}
a.category {
      font-family: Verdana, Arial, Helvetica, sans-serif;
      color: silver;
      font-size: 16px;
      font-weight: bold;
      position:relative;
}

a.category:hover {
      color: #8e8e8e !important;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 16px;
      font-weight: bold;
      position:relative;
}

I'm in a hurry for this so I am giving maximum points.
Thanks
0
Comment
Question by:kareed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 17161984
perl -i.bak -0175 -pe "s/\s*position:relative;.*// if /^\s*a\b/" filename
0
 

Author Comment

by:kareed
ID: 17162101
Hi ozo,
Thanks for the response.  I am trying to modify a string that I already have loaded and done a few other things to.  I also need the "position:relative;" replaced on each of the tags related to "a" such as "a.category:hover", "a.category", "a:hover".  One problem I have is they may or may not be there or there may be new ones.  I just need to make sure that all "position:relative;" with a preceeding "a" gets removed.  Now since I have a terrible time figuring out regexp's, will what you gave me handle this?

my $style = "...the text listed above..."

Thanks again.
0
 
LVL 84

Accepted Solution

by:
ozo earned 2000 total points
ID: 17162193
$style =~ s/(\ba\b[^{]*{[^{]*)\s*position:relative;/$1/g;
0
 

Author Comment

by:kareed
ID: 17162232
Thanks ozo, it worked perfectly.  I really appreciate it.
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!

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
Six Sigma Control Plans
Suggested Courses

770 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