Re: A bit more difficult than usual questions



Am 13.05.2011 16:14, schrieb gpadu99:
On May 13, 4:06 pm, Icarus Sparry<i.sparry...@xxxxxxxxx> wrote:
On Fri, 13 May 2011 06:57:21 -0700, gpadu99 wrote:
Hi all,

I would like to replace a string in a number of files. The problem is
that the string to find is different than what I want to replace. More
clearly: I want to find all instances of string "ABBB.C" and I want to
replace "BBB" with "DDD". That means that after the operation, all my
files should contain the string "ADDD.C"

Any tips are much appreciated

Your question is not very clear! You can replace ABBB.C with ADDD.C and
that will do what you want. If you are trying to suggest that the "A" and
".C" parts are variable then it might be that you want to look at "back-
references". e.g. using 'sed'
sed 's/\(A\)BBB\(\.C\)/\1DDD\2/' oldfile> newfile

Actually, I described the problem very badly. Yes actuall "A" and "C"
are "variables", in the sense that vary, they could be something else.
So, if I understood your example well, my search expression would be:

sed 's/[\.\ %(,'\''].*AAA[1-9]$/\1BBB\2/g'

Providing some ad hoc regexp string without telling what you want
is useless here.


Is it correct as I wrote it?

I doubt it (for many reasons). If Icarus' guess was right then use
Icarus' solution, if you intended something different then explain
your intention.

A couple samples of the sort "what shall be replaced" and some
samples "what shall not be replaced (and why not)" would help us
to support you.

Janis


Thank you very much for the guidance

.



Relevant Pages

  • Re: VB6 LISTBOX problem
    ... Have a look at the code below, can you do a sort that is faster ... There are of course all sorts of ways of sorting stuff, especially stuf that is "linked together" as in your UDTs, but to prove the following code sorts it in exactly the same way that your own original code does so, by concatenating all three items of each element into a composite string exactly as you are already doing, but instead of dumping those composite strings into a ListBox it dumps them into a VB string array. ... Private Type SAFEARRAY1D ... Dim StPtr As Long, VAs String, pVAs Long ...
    (microsoft.public.vb.general.discussion)
  • Re: need help sorting text by trailing Numbers Value
    ... You can try the following VBA code and see if it works to give you a sort string you can use. ... Dim strReturn As String ... Then in the next step how could i move all of the trailing Numerical charachters to a new field? ...
    (microsoft.public.access.reports)
  • Re: Sort Type
    ... Like I said, the Space$ function itself it is about 50 per cent faster than the equivalent String$ function, but the main speed improvement will come from minimizing the number of times you call your Normalize function by taking it out of the sort routine itself. ... I can't really comment further on your normalize function since you have not provided a comprehensive sample of the stuff you intend to sort but, whatever function you end up using, my own previous suggestion of normalizing your strings into a temporary array just once and then performing your ShuttleMerge Index Sort on the temporary array will still produce a massive speed increase regardless of what you end up with in your Normalize function. ...
    (microsoft.public.vb.general.discussion)
  • C Sharp sorting considered superior to C by an order of magnitude
    ... following sort algorithms and the following points. ... its own comparision for the types bool, byte, short, int, long, ... single, double and string. ... private CheckBox CHKdeterminism; ...
    (comp.programming)
  • Re: Cant Figure Out How To Sort On Bind
    ... The sort order is not being passed as an argument, ... with the string "searchCache" to create a key for it, ... 'Assign ColumnOrder to ViewState ... Sub GetDataReader(ByVal ColumnOrder As String) ...
    (microsoft.public.dotnet.framework.aspnet)