Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search project for lines with two expressions on them, and replace second expression only

Status
Not open for further replies.

GriffMG

Programmer
Mar 4, 2002
6,333
FR
I think I'm being a bit dim this morning, but I can't seem to work this out for myself.

I have a largeish project and want to replace some text globally, rather than manually.

I want to change lines that run like this:
Code:
<input Type="Button" Name="cmdAcceptRequest" ID="cmdAcceptRequest" Value="Accept Document Request" Class="input-small" onclick="cmdAcceptRequest_onclick(frmAcceptRequest)">

for this:
Code:
<input Type="Button" Name="cmdAcceptRequest" ID="cmdAcceptRequest" Value="Accept Document Request" Class="btnclass" onclick="cmdAcceptRequest_onclick(frmAcceptRequest)">

So there are two conditions to be met to select the line - and I can use a regular expression to find them: 'Type="button".*input-small' but I only want to replace the 'input-small' with 'btnclass'

I know this is a VFP forum, and most of you will spot that the code is HTML, but I manage my web projects using the VFP9 IDE, because I think it rocks.
I could write a quick and dirty app which would do the above, but I'm sure it can be done in the IDE, using code references - but this morning it's beyond me.

Any help gratefully received.


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Indeed you could use CSS like this if all pages at least link to he same css stylesheet.
Code:
body {background-color:#...... !important}

The role of "!important" is that of a sealed property, a type of inheritance VFP doesn't have. It also has its downsides, but in this case, would have made that an easy and sensible fix for the notion to centralize the background color definition. See
Anyway, the way CSS is linked into HTML isn't really inheritance and the way CSS attributes are inherited from parents also isn't real OOP inheritance. In the end, the general notion is to prevent using !important as far as you can, partly because it'll later become a puzzle why a local color definition doesn't override the color. And the way you got rid of that riddle is by removing the local color definitions, so !important became unimportant and now you can decide to let some pages have specific other background colors again.

Mike, I don't condemn writing such things, it's also easier to get than regex, in many cases, I always curse about these beasts wherever they are the only way to go, too, but they do have extremely detailed features like groups and subgroups.

Bye, Olaf.

Olaf Doschke Software Engineering
 
body {background-color:#...... !important}

Olaf, where were you this morning when I was given this job? (Actually, I do know about [tt]!important[/tt] but for some reason the knowledge was absent from my brain.)

Code that takes 10 minutes to write, but an hour to run, or code that takes an hour to write and 10 minutes to run?

I would always go for the former. An hour of my time is worth more than ten minutes of the computer's. In this case, though, the issue didn't arise. The code ran in roughly the time it took to start releasing my finger from the mouse button on clicking "OK" to run the program, to finishing releasing the aforesaid digit. This is VFP, after all.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top