Link to home
Start Free TrialLog in
Avatar of kareed
kareed

asked on

how do I remove this string

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
Avatar of ozo
ozo
Flag of United States of America image

perl -i.bak -0175 -pe "s/\s*position:relative;.*// if /^\s*a\b/" filename
Avatar of kareed
kareed

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kareed

ASKER

Thanks ozo, it worked perfectly.  I really appreciate it.