Solved

how do I remove this string

Posted on 2006-07-22
4
159 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
  • 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…

856 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