Solved

how do I remove this string

Posted on 2006-07-22
4
156 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now