Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Pls help with what (should be) a simple substitution exp?

6 views
Skip to first unread message

BobMCT

unread,
Apr 1, 2013, 2:51:02 PM4/1/13
to
I'm trying to create a simple sed script that will perform the
following on the source files I pass to it:

I'm converting a zillion older but functional programs (perl & php)
where the original author did not enclose operators such as = with
spaces. I'm trying to create a substitution that does that.

If the statment looks like: $field1=$field2;
it will end up looking like: $field1 = $field2;

Of course there are numerous exceptions but I've started with
something like this:

# sed file to insert spaces around equal sign(s)
s/[a-zA-Z0-9\]]/$1\ \=\ /g
s/\=[a-zA-Z0-9\]]/\= \$1/g

And I'm having trouble with the parameter phrasing (i.e.: referencing
what led up to the match and also what may follow the match.

I've looked through my O'Reilly books on the subject and searched
reasonsly well on the web but this must be more specific than I can
find.

Can someone please advise as to how I can modify this to funtion as
expected?

Thanks
0 new messages